Whats wrong with my code 6/5


#1

speed dial to the lesson

I’VE been stock on the lesson for few days and can’t figure out what is going on.
The error comment I receive is "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!).
My code as follow:

puts "Enter some text: "
text = gets.chomp

puts "Enter words to redact: "
redact = gets.chomp

words = text.split(" ")
words.each do |x|
if x == redact
print "REDACTED"
else
print x + ""
end
end

Please help me figure out my problem.
Thank you


#2

Please remember to post a link to the exercise. We do not have them on speeddial. Also include any error messages (SCT and/or console). Thanks.


#3

Hello mtf,
I have updated my post.
Thanks


#4

One thing that jumps out is the missing space character:

"REDACTED "

#5

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