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

how do i delete a variable

i've tried using del planned =5 with no luck, i've also tried del current with no outcome what am i doing wrong

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

del planned=5
planned = 5
del '5'
del var = 'planned = 5'
del 'planned' 
del " planned "
del current_count - '5'
del current_count = 14

Thanks I was on the wrong line, I figured it out finally. thank you for the help.. ??

2 Answers

Hello Sean Fitzpatrick,

del keyword is used to delete variable. In your code you tried to delete variables with assignments. It not work. Just use the variable name after the del

del current_count

del 5?

No use variable name.. example: If you want to delete item from a list, my_list = [1, 2, 3, 4, 5] del my_list[1] will delete '2' from the list.