Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Microsoft Windows [Version 10.0.18362.535]
- (c) 2019 Microsoft Corporation. All rights reserved.
- C:\Users\tomer>python
- Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
- Type "help", "copyright", "credits" or "license" for more information.
- >>> class Character():
- ... def __init__(self, name):
- ... self.name = name
- ... self.affection = 1
- ...
- ... sam = Character("Sam")
- File "<stdin>", line 6
- sam = Character("Sam")
- ^
- SyntaxError: invalid syntax
- >>> lulu = Character("Lulu")
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- NameError: name 'Character' is not defined
- >>>
- ... npc_dictionary = {"Sam": sam, "Lulu": lulu}
- Traceback (most recent call last):
- File "<stdin>", line 2, in <module>
- NameError: name 'sam' is not defined
- >>>
- ... print(npc_dictionary["Sam"].affection) # prints 1
- Traceback (most recent call last):
- File "<stdin>", line 2, in <module>
- NameError: name 'npc_dictionary' is not defined
- >>> npc_dictionary["Sam"].affection = 10
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- NameError: name 'npc_dictionary' is not defined
- >>>
- ... print(npc_dictionary["Sam"].affection) # prints 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement