So I just wanted to know the reason and cause of error I am getting in order to get a better understanding of python.
Here is what I have tried.
Code snippet #1
x,y=int(input()),int(input())
print(x,y)
print(type(x))
print(type(y))
So I get the output -
4
6
4 6
<class 'int'>
<class 'int'>
I am fine with the output, but what bugs me is why I can't use it in the manner like -
Code snippet #2
x,y= int(input().split('-'))
print(x,y)
print(type(x))
print(type(y))
So here, on wrapping input().split() inside int(), it throws an error as :
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
My Doubt
I just want to know why I cannot wrap int() inside input().split() ? Is there an alternate way to do it? Or if it's not allowed please explain why.
mapto make it work.