Setting up the 'Else' branch


Hey , Anyone have the solution?
I am stuck at this exercise !
The code is not working at all…

print "Pleathe enter a thtring: "
user_input = gets.chomp

if user_input.include? "s"
user_input.gsub!(/s/, “th”)
else prints "there is no ‘s’"

Replace this line with your code.

<do not remove the three backticks above>


Is that line even asked for?

Did you mean, puts, or print?


Actually, I tried this version too but it’s not working neither:

print "Pleathe enter a thtring: " 
user_input = gets.chomp
if user_input.include? "s"
  user_input.gsub!(/s/, "th")
  else puts "there is no 's'"


Please post a link to the lesson. Thanks.



I’ll have to go back to the beginning to read all the instructions, because my code does have the .downcase! but on the gets.chomp. That shouldn’t be an issue, though, either way. You have to make sure there is at least one uppercase letter in the input string if that method is being applied, else it returns nil.

Your input would be appreciated! surprise
undefined method `include?' for nil:NilClass
Your input would be appreciated! Surprise
Your string: thurprithe

It should not matter to Ruby how you indent, but for the reader, it’s nice to see structures line up and the code statements have their own block.

if ___
  # code
  # code

As you progress along, string interpolation is a handy feature in Ruby.

  puts "Your string: #{user_input}"
  puts "Yes, there are no 's's"

The argument may be any expression or value.


I’m having the same issue!


Be sure your input has at least one uppercase letter.


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