M
M
mikki200412020-12-03 23:31:35
Python
mikki20041, 2020-12-03 23:31:35

Removing a given from a list?

Hello, how can I make it so that the user is prompted to enter a number from 1 to 10, by entering any number he will be shown a specific phone number from the numbering, and if he tries to enter another number will give an error?

electronics_store = ['Samsung S9+', 'Samsung S10', 'Samsung S20Ultra','Samsung S20+','Samsung S20','Huawei P30','iPhoneX','iPhone11','iPhone12ProMax','iPhoneSE']
print('Введите число от 1 до 10: ')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GlamorousCar, 2020-12-03
@mikki20041

n = int(input('Введите число от 1 до 10: '))
if n <=10 and n >=1:
  print(electronics_store[n-1])
else:
  print('Неправильное число')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question