Beginner Python: AttributeError: 'list' object has no attribute
问题 The error says: AttributeError: 'list' object has no attribute 'cost' I am trying to get a simple profit calculation to work using the following class to handle a dictionary of bicycles: class Bike(object): def __init__(self, name, weight, cost): self.name = name self.weight = weight self.cost = cost bikes = { # Bike designed for children" "Trike": ["Trike", 20, 100], # Bike designed for everyone" "Kruzer": ["Kruzer", 50, 165] } When I try to calculate profit with my for statement, I get the