Advertisement
Alelluja

Untitled

Oct 27th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2. 4/4
  3.  
  4. Variables
  5.  
  6. Trying to reference a variable you haven't assigned to causes an error.
  7. You can use the del statement to remove a variable, which means the reference from the name to the value is deleted, and trying to use the variable causes an error. Deleted variables can be reassigned to later as normal.
  8. >>> foo = "a string"
  9. >>> foo
  10. 'a string'
  11. >>> bar
  12. NameError: name 'bar' is not defined
  13. >>> del foo
  14. >>> foo
  15. NameError: name 'foo' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement