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

iOS Swift Basics (retired) Control Flow For-In Loop

Ludwing Najera
Ludwing Najera
4,596 Points

Invalid escape sequence in literal?

I was just adding in the

\ (number*2)

when an error came up and said it was an invalid escape literal.

what is an invalid escape literal and what is the problem in my code

for number in 1...10 { println("(number) times 2 is \ (number*2)")

}

Andres Oliva
Andres Oliva
7,810 Points

Is that all your code? If you didn't forget the \ before the first string interpolation, then I can't see nothing wrong with your code.

6 Answers

Jeremy Hayden
Jeremy Hayden
1,740 Points

You forgot the \ in the first (number)

Ludwing Najera
Ludwing Najera
4,596 Points

no its in there i forgot to put it in its just that it says it is an invalid escape sequence in literal

for number in 1...10 { println("\(number) times 2 is \(number*2)")

Ludwing Najera
Ludwing Najera
4,596 Points

i do not know what is going on. ;(

Ludwing Najera
Ludwing Najera
4,596 Points

oh i fixed it now its just some case sensitive problem.

the (number*2) was just too far from the backslash

but thanks for the help anyway :D

that is what I was trying to tell you :)

Something is wrong with the forum today because my answer wasn't posted like I had written it, then it posted it like 5 times weird