User input + spaces | Sololearn: Learn to code for FREE!

+1

User input + spaces

Hi, the input is like: num1+num2 I need to split input into 3 fragments: 'num1', '+', 'num2'. But if the user input without spaces, Python treats it like one string (so I cant use index). Can I enforce user's input to add the spaces (num1_space_ + _space_ num2? Thank you!

8/20/2018 3:15:57 PM

Alex

3 Answers

New Answer

+5

If you're going to use eval(), there's a much simpler way >>> eval(input()) 21*2 42

0

Just A Rather Ridiculously Long Username, superb! Thanks a lot!

0