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

Python Python Basics (2015) Python for Beginners Correct errors

Mujahid Chowdhury
Mujahid Chowdhury
5,108 Points

I 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!

errors.py
print("Hello")
name = "Mujahid"
print(name)

print("Let's do some math!")
print("5 + a")


print("Thanks for playing along!')

6 Answers

Look 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.

OK - 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.

HI 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
Mujahid Chowdhury
5,108 Points

Hi 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

:+1: :smile:

Mujahid Chowdhury
Mujahid Chowdhury
5,108 Points

I just tried that and it didnt work. Maybe there is something wrong with the software?

Mujahid Chowdhury
Mujahid Chowdhury
5,108 Points

This 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
Mujahid Chowdhury
5,108 Points

Oh I didnt see that!

Thanks again Steve

No problem! :wink: