Created
October 13, 2021 13:34
-
-
Save driscollis/231c9418d5d9750562d8f06220a03038 to your computer and use it in GitHub Desktop.
Type hinting quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vehicle.py | |
from collections import namedtuple | |
class Vehicle: | |
def __init__(self, name, veh_type): | |
self.name = name | |
self.veh_type = veh_type | |
self.add_ons = [] | |
def add_on(self, name, color, placement): | |
AddOn = namedtuple("AddOn", "name color placement") | |
add_on = AddOn(name, color, placement) | |
self.add_ons.append(add_on) | |
return add_on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks pretty good. I don't think you need [AddOn], but it works for this example