5. Control Flow Know-How failing for unknown reason


#1



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


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 "
    else
        print i + " "
    end
end


#2

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


#3

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


#4

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