Open samp-suman opened 1 year ago
In string you would have learned a method of string - split()
, using this you can take multiple inputs from the user.
For example you want two numbers from user to do some operation-- this is how you will take input of two nos.
a, b = input("Enter two nos. space separated").split()
a=int(a)
b=int(b)
or other way of doing is
a, b = list(map(int, input("Enter two numbers space separated-").split()))
map()
and list()
function you will learn later in the course.
We learned to take input from user, but only one input at a time. So, my question is how can I take multiple inputs in same line. Because I saw in competitive programming most of the questions need multiple inputs in same line. So, how can I code this?