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 trialLudwing Najera
4,596 PointsInvalid 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)")
}
6 Answers
Jeremy Hayden
1,740 PointsYou forgot the \ in the first (number)
Ludwing Najera
4,596 Pointsno its in there i forgot to put it in its just that it says it is an invalid escape sequence in literal
kjvswift93
13,515 Pointsfor number in 1...10 {
println("\(number) times 2 is \(number*2)")
Ludwing Najera
4,596 Pointsi do not know what is going on. ;(
Ludwing Najera
4,596 Pointsoh 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
kjvswift93
13,515 Pointsthat is what I was trying to tell you :)
kjvswift93
13,515 PointsSomething 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
Andres Oliva
7,810 PointsAndres Oliva
7,810 PointsIs 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.