'Multiple int input in same line python [duplicate]

I want to take multiple integer inputs in the same line. I know I can take str input and then convert them into integer in the next line but is there any way I can do it in the same line.

I have tried this:

x,y = int(input("->")).split()
print(x,y)

I am getting this error : ValueError: invalid literal for int() with base 10



Solution 1:[1]

You messed up with parenthesis (split works on string not int) then you expect a tuple for x,y = ...

the solution is:

x, y = [int(i) for i in input("->").split()]
print(x, y)

Solution 2:[2]

You are taking int as input which cant be split

x,y = input("->").split()
print(x,y)

you can change to int if you like later

print(int(x),int(y))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcin Cuprjak
Solution 2