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 trialZachary Wheeler
1,157 Pointshow to delete a variable in python
how do i delete a variable in python?
i wrote del 'planned'
but it comes back with an error each time
current_count = 14
planned = 5
upcoming_releases = 2
2 Answers
David Bath
25,940 PointsDid you actually put planned
in quotes? That would definitely throw an error because in this example planned is a variable. You would need to type:
del planned
kevin mwangi
1,101 PointsHave tried myself but it does not work. It keeps saying it's an error del planned
Kirill Babkin
19,940 PointsKirill Babkin
19,940 PointsHey @Zachary Wheeler, There are two easy ways to delete a variable in Python that i can think of.
1- Use a key word del. There is no need to use quotes with keyword del.
del current_count
2- Set a variable to None. None is similar to null in other languages.
current_count = None
Thank you.