Setting Up the 'If' Branch, Part 1


#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=gets.chomp
user_input.include? "s"


#2

if user_input.include? "s"
    # whatever
end

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"
end

#3

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."
end

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


#4

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


#5

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