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

del(planned) doesn't seem to work for this exercise

Anyone else found this?

delete.py
current_count = 14
planned = 5
upcoming_releases = 2
del(planned)

5 Answers

You don't need to wrap the variable in parentheses :)

Hi shawn,

Thanks for getting back to me; as del is a function and planned is a variable, you do need this format. What's strange is that the code above worked fine in terminal, just not in the html exercise page :( it is this error that I'm flagging to, cheers

del is not a function :) the () are not needed.

Python del operator

remove() however is a function...

Hi shawn, ace thank you for clarifying! So I should have used remove(planned) - good to know. How would you use the del operator (as the example asks 'can you add a new line to delete the planned variable? Use the del keyword, don't just delete the line'). Many thanks in advance

The del operator would be used exactly how you used it...you just don't need the () so..

current_count = 14
planned = 5
upcoming_releases = 2
del planned

I have never really used the del operator but it appears that it is mostly used to delete items out of an array so.

del myArray[3]

which would delete the 4 item in they array name myArray.

I hope that makes sense.

cheers!

Oh I get it! del planned Apologies and thanks for the guidance!

oops sorry I was writing the above response to you when you wrote that you got it so sorry about that :)