Answer the question
In order to leave comments, you need to log in
How to display a list with numbering in Python 3.6.5?
Good day to all. I'm sorry for the stupid question, but could you help me make a list of five elements and then use the loop to display this list by numbering it. It should look like this:
1 pasta
2 cheese
3 milk
... etc.
I created a list. I take it out but I don’t understand how to number it! Can you help and most importantly explain this. Or give a link to a similar article. These cycles are very difficult for me.
ingridient = ['молоко', 'сыр', 'творог', 'кефир', 'яблоко']
for i in ingridient:
print ("%s", %, i)
Answer the question
In order to leave comments, you need to log in
items = ['молоко', 'сыр', 'творог', 'кефир', 'яблоко']
for i, item in enumerate(items):
print(i + 1, item)
items = ['milk', 'cheese', 'cottage cheese', 'kefir', 'apple']
length = len(items)
for i in range(length):
print(str(i + 1), item[i] )
items = ['milk', 'cheese', 'cottage cheese', 'kefir', 'apple']
length = len(items)
for i in range(length):
print(str(i + 1), item s[ i ])
forgot the 's' at the end of the variable name items
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question