Ask coding questions

← Back to all posts
What's going wrong?????
KobeFF (1260)

ok homies so i made this thingy called math tutor as you all know, and it's supposed to solve math problems to make life easier for me, but it's gone wonky and i don't know whats going wrong. HELP!!!

signed, This is driving me crazy!!!! ;P

Answered by blonkm (24) [earned 5 cycles]
View Answer
blonkm (24)

Your inputs are strings (text). Text cannot do math. You need to convert the input to numbers using float() or int().

KobeFF (1260)

@blonkm wow, thanks! (+5 correct answer)

theangryepicbanana (1688)

As a word of advice, you can just do gets.chomp without the !. Otherwise it seems fine

Grify (169)

I'm not getting an error so I need more info on what the problem is in order to help you

KobeFF (1260)

@Grify ok so when you run it, it's supposed to get two numbers and store it in two variables, user_num_1 and user_num_2. but when it's supposed to add/subtract/multiply/divide, it doesn't display the answer, and instead displays the message i made when something goes wrong, the else loop.

Grify (169)

@KobeFF try logging the error itself with a try: catch: throw(err)