Don't know where is the problem


#1

Hi guys,
I don't know where is the problem. Can you help?

print "whats your name?"
user_imput = gets.chomp
user_imput.downcase!

if
user_imput.include? ( "s" || "S" )
print "ok"
end

It seems like I "forget to call .include? on user_input."
how to correct it?


Daffy Duck, .include? not recognized?
#2

Compare the spelling to your code.


#3

user_input or user_imput doesn't matter because is a variable

Also I'm stuck in here, it says that i forgot to call .include?

print "hi"
user_input = gets.chomp
user_input.upcase!
if user_input.include? "S"
print user_input
else print "HAS NO S"
end


#4

User input cannot be an empty string, .downcase! and .upcase! methods return nil if no changes are made. This will raise the undefined method error.

The exercise uses .downcase! so the input must contain at least one capital letter. The work around is to write the modifier as an assignment, rather than in place.

user_input = gets.chomp.downcase

or

user_input = gets.chomp
user_input = user_input.downcase

This way it doesn't matter what the user inputs. Both of the above will work and pass.


#5

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