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 trialMujahid Chowdhury
5,108 PointsI dont understand the question
Hi, I dont understand how to fix the followng line of code:
print(5 + "a")
I tried:
print("5 + a")
and
print("5" + "a")
Please help!
print("Hello")
name = "Mujahid"
print(name)
print("Let's do some math!")
print("5 + a")
print("Thanks for playing along!')
6 Answers
Steve Hunter
57,712 PointsLook at the error that this throws; you've got a badly formatted string in the last line. You need to amend the single quote to a double quote at the end of the string.
Steve.
Steve Hunter
57,712 PointsHI Mujahid,
I just changed that to print(5 + 1)
and that got through. I switched the string "a" to a number so that the inside of the print parentheses was a sensible mathematical operation.
Hope that helps,
Steve.
Mujahid Chowdhury
5,108 PointsHi Steve,
Okay I didnt know we were allowed to change the letter "a" to a integer in this exercise. Simple solution then :)
Thanks for your help
Kind Regards
Mujahid
Steve Hunter
57,712 Points
Mujahid Chowdhury
5,108 PointsI just tried that and it didnt work. Maybe there is something wrong with the software?
Mujahid Chowdhury
5,108 PointsThis is what I done:
print("Hello")
name = "Mujahid"
print(name)
print("Let's do some math!")
print(5 + 1)
print("Thanks for playing along!') # <- string needs surrounding with " and "
Mujahid Chowdhury
5,108 PointsOh I didnt see that!
Thanks again Steve
Steve Hunter
57,712 PointsNo problem!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsOK - the error isn't that clear:
SyntaxError: EOL while scanning string literal
. That means it was midway through a string when it encountered an EOL, or end of line. So, the string wasn't terminated properly.Amend the last line from:
print("Thanks for playing along!')
to
print("Thanks for playing along!")
I hope that fixes it for you!
Steve.