Having issue with "Up the Down Staircase"

The question is :
Use .upto to puts the capital letters “L” through “P”.

(Make sure to use puts and not print, so each letter is on its own line!)

my answer is :
“L”.upto(“P”) { |letter|
print letter, " "

however, it does not think this is the correct answer. I keep getting error message: It looks like you didn’t print out L using puts. Make sure you’re using capital letters!

I have tired putting puts and print even though the instructions say to puts.
Anyone see something wrong that I must be overlooking?

Thank you!

You need to use puts so that every letter is on its own line, rather than all on one line.

But let’s break the code down to understand what it’s doing:

"L".upto("P") { |letter| print letter, " " }

From L up to P, print each letter and add a space after each.

# Output 
# L M N O P

Now you want to use puts, in order to get the following:

# L
# M
# N
# O
# P

Now the tricky bit here, is that you don’t really need a space after each letter.

Or in other words, you’ll want to get…


… but with each letter on its own line.

1 Like

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