Benjamin Roy
Benjamin Roy

Reputation: 37

how to take 10 inputs from user in a single line in python3?

The user need to input space separated values and finally the enter button to submit. I have tried the below code but can't restrict to only 10 inputs. for eg- first ask for number of inputs. Then followed by the ten inputs whichare space separated in single line.

#input in single line separated by space(Python3).
n=int(input())    
a=[int(x) for x in input().split(), range(n))]

Upvotes: 0

Views: 46

Answers (1)

FindOutIslamNow
FindOutIslamNow

Reputation: 1236

Simply :

if len(a) != 10:
   print("len is not correct")
else:
   print("good")

Upvotes: 1

Related Questions