The console isn't reading the "s" in my code


I've followed the examples exactly and even I've even tried a few different inputs found online that haven't been introduced yet and ruby still reads it as the first print line as opposed to replacing the "s" with "th" as it's supposed to. Am I doing something wrong? I haven't moved any further yet, but here is my code.

print "string please: SOSSAMAN"
user_input = gets.chomp

if user_input.include? "s"
user_input.gsub!(/s/, "th")

and the output

string please: SOSSAMAN


The code below should work:

print "string please:"
user_input = gets.chomp

if user_input.include? "s"
  user_input.gsub!(/s/, "th")

You should be prompted to enter in your text - at which point you put in SOSSAMAN and hit enter. Then it will alter and display your output.


Hey thanks man! I can't believe the answer was that simple haha, I guess I took the initial string a little too literal and saw it was asking for input in the strong rather than after the code was submitted. Great response!


Here is my code:

#Asks the user for a word
puts "Input a word"
user_input = gets.chomp

#If the user doesn't type in a word, then the system will keep asking the user to type a word until they do
while user_input.empty? == true do
    puts "Please type in a word"
    user_input = gets.chomp

#Creates a new variable called user_input_lower that is the lower case of user_input
user_input_lower = user_input.downcase

if (user_input_lower.include? "s") || (user_input_lower.include? "ce") || (user_input_lower.include? "ci") || (user_input_lower.include? "cy") 
    user_input.gsub!(/ce/, "the")
    user_input.gsub!(/Ce/, "The")
    user_input.gsub!(/ci/, "thi")
    user_input.gsub!(/Ci/, "THi")
    user_input.gsub!(/cy/, "thy")
    user_input.gsub!(/Cy/, "THy")
    puts "Your final string: #{user_input}"
    puts "You do not have a letter in your word that sounds like an 's'"

The part where I check for the letters seems messy to me though. I don't understand why the .include? method won't accept the or function || unless I rewrite the entire .include? again.

Anyone have an idea on how to clean it up?