Redacted, Not sure what's wrong


#1



It looks right but I'm getting an error message? Can you tell me what to fix and why?


https://www.codecademy.com/en/courses/ruby-beginner-en-mzrZ6/0/5?curriculum_id=5059f8619189a5000201fbcb

Oops, try again. Make sure to print each word from the user's text to the console unless that word is the word to be redacted; if it is, print REDACTED (all caps!).


Replace this line with your code. 
text = gets.chomp
puts text
redact = gets.chomp
puts redact

words = text.split (" ")

words.each do |word|
   if word != redact
       print word + (" ")
else 
    print "REDACTED"
end
end


#2

No parens needed on this. If the SCT is looking for ... + " " it will not find it.

As for built in methods, be in the habit of keeping the parens tight to the method name:

.split(" ")

#3

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