If, Else, and Elsif help



It accepts the code but it's not printing out correctly- it if you imput your name, it should convert to integer then print the correct phase of if statement. Any ideas?

print "what is your name?"
name = gets.chomp.to_i
if name > 5
    print "that's a long name!"
elsif name < 5
    print "That's a short name!"
    print "Good average sized name"


Hello :slight_smile:

It looks like you want to get the length of the name. Instead of to_i you have to use length. Take a look:

=> 0
=> 12

=> 6
=> 2


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