+ 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?
3 Réponses
+ 3
txt = input("Enter 5 names separated by space")
names = txt.split()
print(names)
INPUT:
Preity Harshita Rohit Diljit Roshni
+ 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)
0
Thanks...