+ 2
How to limit the number of inputs in python syntax input().split() from user ?
The coding should be short as mush as possible
2 Answers
+ 9
The clean way would be to take the inputs separately in a loop, just as many as you want, and to check for proper input and communicate with the user.
If it has to be short, you could also do something like this:
inputs = [input() for i in range(5)]
Or, if the input has to come in one line and separated by space, you just throw away the inputs you don't want:
inputs = input().split()[:5]
+ 1
Thank you.After day of searching.But I use like this:
inputs = [input() for i in range(n - 1)]