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

i am stuck on this question can someone help i just started

i am stuck because i don't get the question that much and i don't know what to do

current_count = 14
planned = 5
upcoming_releases = 2
Paul West
Paul West
6,925 Points

What it is asking you to do is get rid of the variable with python this is done with the del key word

try this:

current_count = 14 planned = 5 upcoming_releases = 2

del planned

2 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Use the del keyword followed by the name of the variable you want to delete.

Emerson Rubio
Emerson Rubio
18,017 Points

These two methods work on Python 2 & 3

method 1

planned = 5
print(planned) #prints 5
del(planned) #deletes the variable planned
print(planned) #Should return this error: "name 'planned' is not defined"

method 2

planned= 5
print planned #prints 5
del planned #deletes the variable planned
print planned #Should return this error: "name 'planned' is not defined"

By using del or del( VARIABLE_HERE ) you can delete any variable. This is how you can delete variables using del!