Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Megan Weber
27,261 PointsSass for loop error
I'm trying to use a for loop to append values to my list variable, ra
.
This is my code:
$ra: ();
@for $i from 1 through 10 {
append($ra, $i, comma);
}
I'm getting this error:
Error: expected "{".
append($ra, $i, comma);
style.scss 3:24 root stylesheet
2 Answers

Rich Donnellan
25,767 PointsWhat are you trying to accomplish? The @for
loop expects some kind of CSS output. It seems like you're just trying to programmatically store the values 1-10
in a variable.

Megan Weber
27,261 PointsI just needed to assign the value returned by append()
to $ra
.
Megan Weber
27,261 PointsMegan Weber
27,261 PointsYes. I wanted to store different shadows in the list & after the loop set an element's box-shadow property to the list. I got the same error when I tried that, so I thought I should simplify the code until I get the loop working.
Rich Donnellan
25,767 PointsRich Donnellan
25,767 PointsGotcha! Can you link me to a snapshot (e.g. Workspace, Codepen, Sassmeister, etc) of your full code? I can try to help you work this out.
This blog post might be of help: https://hugogiraudel.com/2013/07/15/understanding-sass-lists/
Megan Weber
27,261 PointsMegan Weber
27,261 PointsAfter reading the article, I tried assigning the value returned by
append()
to$ra
, & it worked! Thanks for your help :)Rich Donnellan
25,767 PointsRich Donnellan
25,767 PointsAwesome! Can you post as an answer what worked on the off chance it might help someone else here?