repetition
Making a longer string or list by repeating one with *, as in "-" * 10.
In more detail
The count must be an integer, and either order works: 3 * "ab" gives "ababab". The same symbol means multiplication for numbers, which is why the type of each operand matters.
Example
"ha" * 3 # "hahaha"Related terms
- concatenation — Joining two strings or two lists end to end with +, as in "Hello, " + name.
- arithmetic operator — A symbol that does arithmetic on numbers: + add, - subtract, * multiply, / divide, // floor divide, % remainder and ** power.
Taught in
- Strings, Delimiters And Concatenation — Hands-on Python: Complete Video Course & Book
- Lists, Range And The For Loop — Hands-on Python: Complete Video Course & Book
- Repeat Loops And Successive Modification — Hands-on Python: Complete Video Course & Book
- Mad Libs Revisited: Finding The Cues — Hands-on Python: Complete Video Course & Book
- Mad Libs Revisited: The Whole Program — Hands-on Python: Complete Video Course & Book
- Animation: Loops, Bouncing, Flushing — Hands-on Python: Complete Video Course & Book
- Thirty Questions, One Sneaky Print — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Comparing, Slicing And Never Changing — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep