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,713 Points

You're missing the do keyword, Try this

for item in ["Programming", "is", "fun"] do
  puts item
end
K .
K .
2,356 Points

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

Osman Ercanli
Osman Ercanli
3,579 Points

thank you so much Samuel