How to take two inputs in one line separated by space in python

  input, python-3.x, valueerror

So I am practicing in hacker earth and I have to take two inputs in a single line separated by space.
The below code is what I used:

 x, y = [x for x in input("Enter two value: ").split()]

It is supposed to take input that looks like ‘2 5’

And it is returning an error:

Execution failed
ValueError : not enough values to unpack (expected 2, got 1)

Stack Trace:
Traceback (most recent call last):
File "/tmp/165461120/user_code.py", line 13, in
x, y = [x for x in input("Enter two value: ").split()]
ValueError: not enough values to unpack (expected 2, got 1)

What I think I understood is that it is giving two values as a single string. If so how do I take separate them and convert them into integers?

Source: Python-3x Questions

LEAVE A COMMENT