Oops, try again


#1



https://www.codecademy.com/courses/ruby-beginner-en-XYcN1/2/5?curriculum_id=5059f8619189a5000201fbcb#

Oops, try again. It looks like your iterator syntax isn't quite correct--check the Hint if you need help.
(ruby):1: syntax error, unexpected $end

list1 = [1, 2, 3,4,5]
 for i in range(0,len(list1)) ;

#2

The above is Python code, not Ruby. In Ruby a range is written,

0..array.length (inclusive of last value in range)

or

0...array.length (exclusive of last value range)

So a for loop would look something like this...

for i in 0...list1.length
    puts list1[i]
end

Only problem is that lesson 12 asks us to use the .each method for this loop.


#3

@mtf thank you for your help! smile:


#4

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