Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python for Beginners Correct errors

Abraham Yeransian
Abraham Yeransian
9,346 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!')