What went wrong?


Hello, I am trying to complete the extra practice on ''Think about how you might preserve the user's original capitalization". Can someone kindly explain what went wrong and what the error is saying?

print "input please"
user_input = gets.chomp
if user_input.include? "s" || user_input.include? "S"
    user_input.gsub!(/s/, "th")
    user_input.gsub!(/S/, "th")
    print "there is no s \n" #\n enters a new line for next string


puts "my string is #{user_input}"

The error result is as follow
(ruby):2: syntax error, unexpected tSTRING_BEG, expecting keyword_then or ';' or '\n'
if user_input.include? "s" || user_input.include? "S"
(ruby):5: syntax error, unexpected keyword_else, expecting $end


Seems like that reads as:

user_input.include? ("s" || user_input.include?) "S"

I couldn't say why that is though, I'm not that familiar with Ruby, but at least that's a partial explanation


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