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

Abraham Yeransian
Abraham Yeransian
10,771 Points

Challenge errors.py

I can not figure out what exactly they are asking for. To fix the (5 + a) I would only have to assign a variable to "a" but that does not work.

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

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

print("Thanks for playing along!')

1 Answer

Sergii Guk
Sergii Guk
2,037 Points

Hi Abraham, You didn't fix some of the issues, and have one mistake in your code:

1

Here you have a mistake

a = name
print(name)

'name' variable is not defined, so 'a = name' is not fixing a problem. There are two solutions:

Option 1. Add quotes before and after name, so it will be string, but not a variable

print("name")

Option 2. Or you can define the variable name:

name = "Abraham"
print(name)

2

this mistake is not fixed in your code:

print(5 + "a")

you cannot add different types to each other (integer '5' and string 'a'). So here also are two possible solutions:

Option 1. Add quotes for '5', so it will become string, not integer:

print("5" + "a")

Option 2. Define 'a' as integer variable and remove quotes for it:

a = 10
print(5 + a)

3

this mistake is also not fixed in your code

print("Thanks for playing along!')

string should begin and finish with the same type of quotes. And here you also have two options:

Option 1. Change quotes to following:

print("Thanks for playing along!")

Option 2. Or change quotes to following:

print('Thanks for playing along!')