Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. Microsoft Windows [Version 10.0.18362.535]
  2. (c) 2019 Microsoft Corporation. All rights reserved.
  3.  
  4. C:\Users\tomer>python
  5. Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
  6. Type "help", "copyright", "credits" or "license" for more information.
  7. >>> class Character():
  8. ...   def __init__(self, name):
  9. ...      self.name = name
  10. ...      self.affection = 1
  11. ...
  12. ... sam = Character("Sam")
  13.   File "<stdin>", line 6
  14.     sam = Character("Sam")
  15.       ^
  16. SyntaxError: invalid syntax
  17. >>> lulu = Character("Lulu")
  18. Traceback (most recent call last):
  19.   File "<stdin>", line 1, in <module>
  20. NameError: name 'Character' is not defined
  21. >>>
  22. ... npc_dictionary = {"Sam": sam, "Lulu": lulu}
  23. Traceback (most recent call last):
  24.   File "<stdin>", line 2, in <module>
  25. NameError: name 'sam' is not defined
  26. >>>
  27. ... print(npc_dictionary["Sam"].affection) # prints 1
  28. Traceback (most recent call last):
  29.   File "<stdin>", line 2, in <module>
  30. NameError: name 'npc_dictionary' is not defined
  31. >>> npc_dictionary["Sam"].affection = 10
  32. Traceback (most recent call last):
  33.   File "<stdin>", line 1, in <module>
  34. NameError: name 'npc_dictionary' is not defined
  35. >>>
  36. ... print(npc_dictionary["Sam"].affection) # prints 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement