This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by JAPJr
over 10 years

Glitch in system?

There seems to be a glitch in the system. For the redacted problem I wrote the following code:

puts “Enter a line of text.” text = gets.chomp puts “Enter a word to redact from the line of text.” redacted_word = gets.chomp words = text.split(“ “) words.each do |word| if word == redacted_word print “REDACTED “ else print word + “ “ end end

It worked perfectly. When given a line of text and a word to redact, it would print out the line of text, but with the word to redact replaced by REDACTED. However, the system keeps giving me an “Oops, try again” message.

Answer 535cb8b97c82ca8e2b0017fb

0 votes

Permalink

Your code worked for me, and printed a green “Way to go!”

Mine was acting weird as well but seems fine now…

points
Submitted by tmowad
over 10 years

Answer 5363231780ff33fbd0000dd5

0 votes

Permalink

I’m having the same issue. It’s showing the code as working perfectly, but I’m getting the “Oops, try again” message at the bottom.

points
Submitted by Anne N
over 10 years

Answer 536325bb282ae38916000c51

0 votes

Permalink

I think I figured out the glitch. If I run the code and enter a string of text, then enter a word to be redacted that ISN’T in the sentence, it magically tells me I’m correct and lets me move on. Definitely a bug I think.

points
Submitted by Anne N
over 10 years

Answer 5365202c80ff334858001c4b

0 votes

Permalink

the code works fine but in order to not get “Oops try again” you need to indent you code properly

points
Submitted by kelle84
over 10 years

Answer 538224248c1ccc4f2c004f52

0 votes

Permalink

For my issue, I just had to add a space after the redaction, like this: “REDACTED “

Here is my code that worked:

puts "Enter a string: "
text = gets.chomp
puts "Enter another string: "
redact = gets.chomp

words = text.split(" ")

words.each do |word|
    if (word == redact)
      print "REDACTED "
    else
      print word + " "
    end
end 
points
Submitted by Greg Greenleaf
over 10 years