+ 2
How do I use an if statement with gets.chomp?
I always get the "wrong answer" https://code.sololearn.com/cY3toiQ4OSSG/?ref=app
3 Answers
+ 3
Input is a string. You must make it an integer like this:
ans = gets.chomp.to_i
+ 4
Thanks guys!
+ 3
The input is converted to a string. Try:
if ans == "3"
that should fix your problem.