+ 1

How to take multiple inputs in python?

Suppose we want user to input some 9 values of string or number, then it's quite difficult to add input function for each time, so in this case how slcan we specify a range like, askimg user to input 5 no.s/strings?

27th Apr 2021, 9:59 AM
Harshita Sharma
Harshita Sharma - avatar
3 ответов
+ 3
txt = input("Enter 5 names separated by space") names = txt.split() print(names) INPUT: Preity Harshita Rohit Diljit Roshni
27th Apr 2021, 10:06 AM
minirkk
minirkk - avatar
+ 3
a=[input() for i in range(9)] print(a) #more elegant and user friendly version: a = [input(str(i+1)+": ") for i in range(9)] print(a)
27th Apr 2021, 10:11 AM
Shadoff
Shadoff - avatar
0
Thanks...
27th Apr 2021, 10:14 AM
Harshita Sharma
Harshita Sharma - avatar