Elsif statement


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-ruby/lessons/control-flow-in-ruby/exercises/elsif?link_content_target=interstitial_lesson

<In what way does your code behave incorrectly? Include ALL error messages.>
What is wrong with this?

```

print "How old are you?"
user_num = gets.chomp
if user_num < 26
puts "You’re a young gun!"
elsif user_num > 26
puts "You’re old!"
else
puts "we’re the same age!"
end

<do not remove the three backticks above>

#2

what’s the error message you are getting?


#4

print “How old are you?”

user_num = gets.chomp.to_i

if user_num < 26

puts “You’re a young gun!”

elsif user_num > 26

puts “You’re old!”

else

puts “we’re the same age!”

end

convert the input to integer


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.