Redacted, Not sure what's wrong


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

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 + (" ")
    print "REDACTED"


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(" ")


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