4. Setting Up the "if" Branch, Part 1 -- What is wrong ?:c


print "Qué pasa bato?"
user_input = gets.chomp.downcase!

if user_input.include? "s"
print "s"

Error said:"Oops, try again. Your code doesn't look quite right. Check the first exercise if you need help!"


as in this thread, if your input is already lowercase, it will throw an error. Try input something with uppercase.


any chance you could explain why this throws an error?
or how to avoid getting this error?

I'm new to ruby (obviously) but i havent seen this type of behaviour before in other languages i've used.

This seems like a pretty poorly designed exercise for someone learning how Ruby behaves, if the code is correct, but the "wrong" user input returns an error.


use the .downcase! on a new line rather than combining them, otherwise it will throw the error, here is my code here:

print "give me some words: "
user_input = gets.chomp

Hope that helps :smiley:


It does not work this way either :slight_smile:

if user_input.downcase.include? "s"
print "got it !! "

I get the error : Oops, try again.
Don't forget to call .include? on user_input.

But it works fine on my computer. Looks like problem with this interface


Just remove the '!' after downcase. Hope that helps


print 'user_input'
user_input = gets.chomp
print "give an input"
user_input = gets.chomp
user_input2 = user_input
if print "give me some words"
user_input gets.chomp
print "Thtring, pleathe!: "
user_input = gets.chomp

if user_input.include? "s"
user_input.gsub!(/s/, "th")
puts "Nothing to do here!"

puts "Your string is: #{user_input}"

That should work. It worked for me


thank you very much lol


Hi guys,
I am getting the same error for the following code:

print "Enter stuff"
user_input = gets.chomp

if user_input.include? "f"
print "yes, its there"
print "nothing to do here"

ERROR MESSAGE: Oops, try again. Don't forget to call .include? on user_input.
Is it me or Codecademy?