Lesson 4 of Redacted!

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

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

<In what way does your code behave incorrectly? Include ALL error messages.>

So I keep getting this error every time I run the program and it’s mind boggling me. I’ve tried it in many different variations from the community here they all give me the same error message.
Oops, try again. It looks like you didn’t print each word from the user’s text to the console.

``` puts "Type a sentence. " text = gets.chomp puts "Word to redact: " redact = gets.chomp

words = text.split(" ")

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

<do not remove the three backticks above>

Hey hi. I copied and paste your code and it didn’t showed me any errors, but I noticed that it is replacing all the words of the text instead of replacing just the “redact” word. so if the word == redact you should print "REDACTED ", and else you should print the word + " ", try just changing this two lines of code and i think it may help.

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

Same error. I’m not sure what I should do.

1 Like

I’m getting the exact same thing. So lost.

I’m getting the same error. It says my users input is NOT printing into the console, but it clearly is.

1 Like

This was my code and it got through.

puts “text”
text=gets.chomp
puts “redact”
redact=gets.chomp

words=text.split("")

words.each do |word|
print word
end

1 Like

guys i did it got it right just look at it