Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Loops Ruby Iteration For Loops

Osman Ercanli
Osman Ercanli
3,579 Points

help with forloop syntax error

for item in ["Programming", "is", "fun"] puts "Item is #{item}." end

--for the code above I am getting the below error, I can't seem to find what to correct, thank you in advance for any help--

treehouse:~/workspace$ ruby forloop.rb
forloop.rb:1: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
for item in ["Programming", "is", "fun"]
^
forloop.rb:1: syntax error, unexpected ',', expecting end-of-input
for item in ["Programming", "is", "fun"]

2 Answers

Samuel Ferree
Samuel Ferree
31,722 Points

You're missing the do keyword, Try this

for item in ["Programming", "is", "fun"] do
  puts item
end

Jason doesnt use the do keyword in the video though..

Osman Ercanli
Osman Ercanli
3,579 Points

thank you so much Samuel