r/pythonhelp • • Sep 22 '22

Lists and Indexes

So i have been trying to make a program in which the user inputs the amount of elements that they will include in a list. After that they start to input numbers to fill the list. I want to print the list elements separated in each line with their index, like for example.

user input:

>>> 5
>>> 1
>>> 2
>>> 3
>>> 4
>>> 5

output:

list[0] = 1
list[1] = 2
list[2] = 3
list[3] = 4
list[4] = 5

I have not been able to achieve this since apparently I cant print two different things in the same print, i have used sep= '\n' to separate list elements but i cant add their index. Help would be appreciated. Thanks!

2 Upvotes

3 comments sorted by

View all comments

1

u/carcigenicate Sep 22 '22

Have you learned about loops? You can use a loop to call print multiple times.

And there is a way to give multiple elements to print, but it involves a few more advanced topics.