How to take space separated input in Python
This is simple, once you know it. In python, you can take space seperated input using the function split()
Lets see an example
a, b, c = input().split() print(a,b,c)
In the above example, 3 input values separated by whitespace are taken. The default separator of split function is any whitespace. The input is assigned to a second to b, and third to c. If we attempt to input more than three values, it will throw a ValueError: too many values to unpack, since the expected number of values are 3.
Output:
Subscribe
Login
Please login to comment
0 Discussion