Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
For i in range(1,5): Input("enter number {0}". format(i))
5th May 2020, 6:54 PM
Abhay
Abhay - avatar
+ 5
I would also recommend to convert the numbers from input to int or float. I have taken the 2 mentioned for loops and did it with a comprehension: inp = [] [inp.append(int(input(f'Enter {x + 1}. number: '))) for x in range(4)] print(inp)
5th May 2020, 7:13 PM
Lothar
Lothar - avatar
+ 5
OK - here is a more simple code. It takes the 4 inputs and stores them in a list: inp = [] for x in range(4): inp.append(int(input(f'Enter {x + 1}. number: '))) print(inp)
5th May 2020, 7:23 PM
Lothar
Lothar - avatar
+ 4
[Input() for i in range(4)]
5th May 2020, 7:08 PM
Oma Falk
Oma Falk - avatar
+ 1
for i in range(4): a=input("enter number"+str (i+1))
6th May 2020, 5:30 AM
Ashish Singh
Ashish Singh - avatar