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 Data Types Del

Darren Taylor
Darren Taylor
1,038 Points

Hi, I'm trying to delete a variable below that say's "planned = 5", please help, thanks.

Hi, I'm trying to delete a variable below that say's "planned = 5", please help, thanks.

delete.py
current_count = 14
planned = 5
upcoming_releases = 2 
del variable_planned = 5

1 Answer

Ezra Siton
Ezra Siton
12,644 Points

First, in general you try to delete var (del variable_planned), but you don't declare this var - this will throw

"SyntaxError: invalid syntax ".

Test this code: https://repl.it/languages/python3

Second, This is also syntax error (you can not declare var and also del this var like this)

del planned = 5

Third, you need to delete planned var (follow the instructions)

current_count = 14
planned = 5
upcoming_releases = 2
del planned
Darren Taylor
Darren Taylor
1,038 Points

Thank you very much for your assistance Ezra, your help has been excellent!

thanks