0

Is it possible to split an input of two integers separated by a space such as '1 2' to be split into two separate variables? I have tried

ratio = input() a,b = ratio.split(' ') 

but it returns an error message of 'SyntaxError: unexpected EOF while parsing'.

0

1 Answer 1

3

Try using raw_input() instead of input()

raw_input strips trailing newline. https://docs.python.org/2/library/functions.html#raw_input

Sign up to request clarification or add additional context in comments.

2 Comments

It can't be a raw_input() because the numbers need to be integers
You can write it as a,b = map(int, ratio.split(' '))

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.