Control Flow Know How (Redacted) my code works, but still fails


#1

so my code does exactly what it's supposed to do, but I still get the message:
"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!)."

puts "Paste or type something you want 'sanitized' here:"
text = gets.chomp

puts "And what needs to be hidden?"
redacted = gets.chomp

words = text.split(" ")

words.each { |x| 
  if x == redacted 
      print "REDACTED "
  else 
      print x + " " 
  end
  }

#2

Could this be a case for do?

words.each do |x| 
  if x == redacted 
      print "REDACTED "
  else 
      print x + " " 
  end
end

#3

2 posts were split to a new topic: Not sure why this doesn't work