7. Returning the Final String


#1

Something is wrong here, probably many things, but Codeacademy won't tell me what. Can someone clarify please?
print "Insert your non-duckified sentence."
user_input = gets.chomp
user_input.downcase!
if user_input.gsub!(/s/, "th")
puts " Your string is: #{user_input)"
else print "There is no s in this sentence, so it cannot be duckified..."
end


#2

don't you want to go like this . . .

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

you first want to check if there is an "s"
then you want to do the substitution
I think you have those both in one line
if user_input.gsub!(/s/, "th")


#3

Thanks :smile_cat: I had trouble with that one.


#4

Hello I am GT and I am just learning to code. I am having a problem in that I put this line of code in Ruby:

print "stop ask for something"

user_input=gets.chomp

user_input.downcase!

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

else
print "there is no s in this sentence so it cannot be Duckified"

end

The print line has an "s" in it but the code is not picking it up. What am I missing?


#5

i think it goes like this:

print "Give me an input"
user_input = gets.chomp
user_input.downcase!
if user_input.include? "s"
user_input.gsub!(/s/, "th")
else
print "no s's"
end
puts "#{user_input}"


#6

print "Input a string: "
user_input = gets.chomp.downcase
if user_input.include? "s" then
    user_input.gsub!(/s/, "th")
    puts " Your string is: #{user_input}"
else print "Nope!"
end

#7

#{user_input)"

#{user_input}"


#8

thank you so much, I was stuck on that for like ever!


#9