-1
numbers = [5, 2, 5, 2, 2]
for item in numbers:
    print("...")

This just prints the string for each item in the list, but I don't know how to make it print said string by the number of times as the item in the list.

Ken White
  • 123,280
  • 14
  • 225
  • 444

1 Answers1

0

In python you are allowed to use multiplication (*) between an integer and a string which should do what you want.

numbers = [5, 2, 5, 2, 2]
for item in numbers:
    print(item * "...")

Result is

...............
......
...............
......
......
FGreg
  • 14,110
  • 10
  • 68
  • 110
  • THANKS. Would you mind explaining to me what exactly we're asking the program to execute? – Paballo Mogane Apr 19 '22 at 01:06
  • You are taking the string value of `"..."` and multiplying it by an integer. Then you print the result. So if the integer is 2, the program multiplies `"..."` by 2 making `"..."` and `"..."`, then prints it resulting in `......` – FGreg Apr 19 '22 at 01:31