Input problem

why do I need to take input like this:
num1,num2 = map(int,input().split())
when i can just take input like that:
but this value error

The input is given in a single line spaced and hence, you gotta use map.

we use map to get input in single line and spaced rather than in different line

1 Like

Because the input provided is a single line spaced.

The map take values entered after space, in a single line. Whereas assigning it to other line, result in taking input in two lines.

map() takes two arguments. The first one is the method to apply, the second one is the data to apply it to. By this understanding, we can see this is doing nothing but typecasting every element of the list to an integer value.