Control Flow Know How


#1



https://www.codecademy.com/courses/ruby-beginner-en-mzrZ6/0/5


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!).

This is my code. I'm not sure why I'm getting the error message. Can someone please help me. Thanks in advance!

puts "Need input:"

text = gets.chomp

puts "What word are we redacting?"

redact = gets.chomp

words = text.split (" ")

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


#2

Don't forget the white space.

"REDACTED "


#3

Thank you Mtf! I appreciate the help!


#4

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