Home > OS >  I need to create a loop that prints a graph where each number in the list is shown by a number of ch
I need to create a loop that prints a graph where each number in the list is shown by a number of ch

Time:01-25

numbers = [1,2,3,4]

results in

1: i

2: ii

3: iii

4: iiii

This is my code so far and I'm not sure where to go.

numbers = [1,2,3,4]

c = 0

for i in numbers:

    count  = 1

print(len(numbers))

CodePudding user response:

Instead of 'i' you can put any character you like enclosed in single inverted commas.

numbers = [1,2,3,4]
output = []
for number in numbers:
    output.append(number*'i')

print(output)
  •  Tags:  
  • Related