Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created May 15, 2023 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephengruppetta/cc8d275542385e5099535f796bd5128a to your computer and use it in GitHub Desktop.
Save stephengruppetta/cc8d275542385e5099535f796bd5128a to your computer and use it in GitHub Desktop.
# making_magic.py
from hogwarts_magic import Wizard, House
harry = Wizard("Harry Potter", "stag", 1980)
hermione = Wizard("Hermione Granger", "otter", 1979)
gryffindor = House(
"Gryffindor",
"Godric Gryffindor",
["scarlet", "gold"],
"lion",
)
print(harry.name)
# Harry Potter
print(harry.house)
# None
print(gryffindor.members)
# []
harry.assign_house(gryffindor)
print(harry.house.name)
# Gryffindor
for member in gryffindor.members:
print(member.name)
# Harry Potter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment