Home > database >  How to numerate input
How to numerate input

Time:10-16

I wanted to ask how to make the instructions for the user on the screen: enter 1 number enter 2 number, not just enter the numbers.

Thank you in advance!

numbers  = []
limit = 2

for x in range(limit):
    numbers1 = int(input('enter numbers: '))
    numbers.append(numbers1)

print(numbers)

CodePudding user response:

as of python 3.6 this is a correct way to do it using f-strings.

for x in range(limit):
    numbers1 = int(input(f'enter {x 1} number: '))
    numbers.append(numbers1)

CodePudding user response:

You already have an index number on each iteration, that is the variable x. You can just print it together with your input text.

for x in range(limit):
    number = int(input(f'enter number {x}: '))
    numbers.append(number)

If you want so start with 1 instead of 0, you can change your range:

for x in range(1, limit 1):
    number = int(input(f'enter number {x}: '))
    numbers.append(number)
  • Related