4 If branch Part 1

print "what"
user_input = gets.chomp.downcase!

if user_input.include? ("s" || "S")
    print "yup"

receiving the error

Oops, try again. Don't forget to call .include? on user_input.


When you input a string, does it contain at least one UPPERCASE letter? Since you called downcase! right after gets.chomp, if there is no UPPERCASE letter, it returns nil.
Try adding .downcase! on a new line like so:

print "what"
user_input = gets.chomp

See if that solves your problem.

Also, since you have used downcase! on your string, it is already lowercase, so you do not need the OR statement (you will never have a "S"). You can just use the following:

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

And one more thing, you have a blank else, it can be removed


I'm just learning, so I'm not positive. Nonetheless, I think there are a few problems with this code:

in line 2 the downcase! is used incorrectly. It needs to be on a separate line.

user_input = gets.chomp #This code gathers a response from a user
user_input.downcase! #this code makes all letters lowercase in the answer above

if user_input.include? ("s" || "S") isn't correct.

For one, there is no need to search for an "S" because you have made the response all lowercase. There will not be a capital letter anymore.

For two: this isn't how you write an OR statement in this way. If you didn't .downcase! the answer, you could search for the capital letter like this:

if user_input.include? "S"
print "yup"
elsif user_input.include? "s"
print "yup"
print "nope"