Answer the question
In order to leave comments, you need to log in
How to display an item in a list?
Good afternoon everyone. Tell me, how can I enter a number and display exactly the number of elements that I entered from the list? For example:
a = ['раз', 'два', 'три', 'четыре', 'пять', 'шесть', 'семь', 'восемь', 'девять', 'десять']
n = int(input('число, сколько слов нужно вывести'))
Answer the question
In order to leave comments, you need to log in
>>> a = ['раз', 'два', 'три', 'четыре', 'пять', 'шесть', 'семь', 'восемь', 'девять', 'десять']
>>> n = 1
>>> a[0:n]
['раз']
>>> n=3
>>> a[0:n]
['раз', 'два', 'три']
>>> n=5
>>> a[0:n]
['раз', 'два', 'три', 'четыре', 'пять']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question