5. Control Flow Know-How failing for unknown reason



When executed, the code below does indeed replace the redacted words with "REDACTED " It prints the other words as the user entered them (with the appropriate " " after each one).

However, the tutorial responds with "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!)."

As far as I can tell, I've satisfied the code specs, but the tutorial will not let me advance. Thank you any and all for your help.

puts "Enter a string please."
text = gets.chomp

puts "Enter word to be redacted."
redact = gets.chomp

word = text.split(" ") #word is an array

word.each do |i| 
    if i == redact 
        print "REDACTED "
        print i + " "


Your code does pass for me. Cannot reproduce this condition.


Thank you for checking. I changed | i | to | x |, and it passed with no problems. Strange.


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