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

Darren Taylor
Darren Taylor
1,052 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,052 Points

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

thanks