Code accepted but wrong output (5/6)


#1

Hi fellow coders,

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

The exercise accepted my code as correct yet it did not substitute any words with REDACT.

Could you please help me find the error?

text= gets.chomp
puts text 
redact= gets.chomp
puts redact
words= text.split(" ")

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

Thank you very much in advance!


#2

See this:

When this is fulfilled,

it will do as you have told it to...

Else, it will only leave a space as you've indicated here.


#3

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