Setting Up the 'If' Branch, Part 1


Setting Up the 'If' Branch, Part 1

I think that program should return "true" because my code includes "s".
But the program returns only "false". So, if I write "if" statement, it returns the value of the "else" statement
What is problem?

Replace this line with your code.
puts "s"
user_input.include? "s"


if user_input.include? "s"
    # whatever

This is what you need to do - set up and if.

This is my code:

print "Please, give me your thring: "
user_input = gets.chomp.downcase
print "I found letter s\n" if user_input.include? "s"

It could also be:

print "Please, give me your thring: "
user_input = gets.chomp 
if user_input.include? "s"
  print "I found letter s\n"


Apparently this exercise is confusing. I am having the same issue as everyone else. My code:

print "Please enter a string."
string1 = gets.chomp.downcase!
if string1.include? "s"
print "yes to s."

Throws the error: Oops, try again. Don't forget to call .include? on user_input.
What am I missing?


Oh I see! You have to specifically use the string variable "user_input". Duh!


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