I am getting a rutime error in python3.When i am using n=int(input()),k=int(input()) instead of
(n,k)=map(int,input().split()).
why so? The overall concept remains the same bt why is map function used?
input() in Python reads a line. The values of ‘n’ and ‘k’ are given in a single line, separated by a space ’ ’ (according to the input format). So, when the code tries to convert a space to an ‘int’, it throws a RE.
You can even try this on your own machine offline. It should throw an error there too.
map() converts each string element returned by split() to ‘int’ and maps them to corresponding variables in the tuple.