Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created May 15, 2023 19:46
Show Gist options
  • Save stephengruppetta/ec20855ea22533ca6c0e43b341faf1ea to your computer and use it in GitHub Desktop.
Save stephengruppetta/ec20855ea22533ca6c0e43b341faf1ea 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
gryffindor.add_member(harry)
for member in gryffindor.members:
print(member.name)
# Harry Potter
# Harry Potter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment