Exact same code not working as a solution

This is the code I’m trying to use, that isn’t working

print "Pleathe enter a thtring: " 
user_input = gets.chomp
user_input.downcase!
if user_input.include? "s"
  user_input.gsub!(/s/, "th")
else
  puts "There are no 's's in your string."
end

puts "Here'th your new thtring! #{user_input}"

And this is the code that is the solution

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

if user_input.include? "s"
  user_input.gsub!(/s/, "th")
else
  puts "There are no 's's in your string."
end

puts "Your new thtring is #{user_input}."

The only difference is the contents of the string itself, but it says the code isn’t working?

The lesson might be looking for the exact string to compare results. Have you tried using the string originally supplied? Also, please add the link to the lesson.

1 Like

This.

It’s surprisingly common for the lesson’s evaluation routine to fail code which does the job, simply because it is expecting a string or something to be copied verbatim. :slight_smile:

1 Like

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