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!

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

iOS Swift 2.0 Collections and Control Flow Control Flow With Loops Looping Over Ranges

Jakob Wisener
Jakob Wisener
2,860 Points

Looping Over Ranges: for number in 1...10 trouble.

I have just upgraded Xcode to 7.3.1 to Swift 2.2. I am not sure if this has anything to do with my problem, just thought it might be helpful.

I have been following along with the video and have came across a few errors in the first Range Operator. Here it is:

for number in 1...10 { print("(number) times 5 is equal to \ (number * 5)") }

Here are the errors I have been getting:

-Expected ',' separator -Invalid escape sequence in literal -Unterminated string literal

Can anyone help me out? I feel ridiculous.

2 Answers

It looks like you have a syntax error :

for number in 1...10 {
      print("\(number)  times 5 is equal to \(number * 5)") // **\()** <- missing a blackslash 
Jakob Wisener
Jakob Wisener
2,860 Points

You're a life saver Gary! Thanks!

Megan Sheehan
Megan Sheehan
1,835 Points

I also had this same issue, and found that in the video the code has a line break after the \ before (number). Putting everything on one line fixed my errors.

So the way Gary posted was the correct syntax over the lesson.