Still says wrong


#1

Thank you for giving your ideas.
But it still says wrong when I try your code in the editor.

it says:
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!).


Redacted 5/6
#2

@tianshuwang

Unless your code is strictly identical to @faisalalaloola, I suggest that you start your own thread and post your code in order to get proper help.


#3

the code is working at my place maybe you can try each do instead of {}

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

but different blowers are show different message sometimes


#4

@rita315 @arjofocolovi

So my code looks like this:

puts " Enter a String: "
text=gets.chomp
puts "An other string: "
reduct=gets.chomp
words=text.split(" ")

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

And whenever I run it, it says

cannot convert String into Array

Do I have to convert the input into array? using .split??


#5

your print words + "" should be print x+"" because you use |x| as the name for your array


#6

Oh, yeah! It works! Thank you very much!! :smile:


#7

It doesn't matter what type of redact program you write, it gives you that. I've written several, and even cut and pasted some examples from github, and nothing gets rid of that error for me.


#8