This forum is now read-only. Please use our new forums! Go to forums
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
Answer 5363231780ff33fbd0000dd5
Answer 536325bb282ae38916000c51
Answer 5365202c80ff334858001c4b
Answer 538224248c1ccc4f2c004f52
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
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency