Somehow messed up my code 6/6


#1



While messing around with the last bit of code I had my own question: What if user input includes punctuation? How would you get rid of that punctuation so Ruby recognizes "bees" and "bees?" as the same string and can redact both? I messed around for a bit and thought I had a solution when suddenly:

(ruby):6: syntax error, unexpected ',', expecting ')'
crap.gsub (/#{crap}/, " ")
^
(ruby):6: syntax error, unexpected ')', expecting keyword_end
(ruby):19: syntax error, unexpected $end, expecting keyword_end

Confusing as my code includes end and as far as I can tell my syntax is ok?

puts "Feed me, seymore!"
    text = gets.chomp
    text.downcase!
    punctuation = [".",",","!","?"]
    crap = punctuation.split
    if text.include? crap
        crap.gsub (/#{crap}/, " ")
    end
puts "DON'T feed me, seymore!" 
    redacted = gets.chomp
    redacted.downcase!
    remove = redacted.split (" ")
    words = text.split (" ")   
    words.each do |word|
        if word == remove
            remove.gsub(/#{remove}/, "REDACTED ")
        else 
            print word + " "
        end
end


Any help to remove that error is appreciated. It should be noted that I decided to, stupidly, do two things at once and was also trying to redact multiple words. Meaning I haven't 100% tested that code as of right now.


#2

Ruby allows omitting parentheses for function calls, so because of your space before the opening parenthesis that's what you seem to be doing, but (a, b) isn't a valid expression on its own