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
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”)
Thanks I had trouble with that one.
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?
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}”
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
#{user_input)"
#{user_input}"
thank you so much, I was stuck on that for like ever!