Answer the question
In order to leave comments, you need to log in
Python error: what's the problem?
I can't figure out why it gives an error on the last line:
class Address:
def __init__(self, street, city, state, zipcode):
self.street = street
self.city = city
self.state = state
self.zipcode = zipcode
def get_street(self, street):
return self.street
def get_city(self, city):
return self.city
def get_state(self, state):
return self.state
def get_zipcode(self, zipcode):
return self.zipcode
def __str__(self):
return str(self.street,self.city,self.state,self.zipcode)
address = Address('Grandview', 'Westland', 'Michigan', 48186)
street = address.get_street()
city = address.get_city()
state = address.get_state()
zipcode = address.get_zipcode()
print "%s, %s, %s, %s" % (street, city, state, zipcode)
TypeError
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-10-c76c12dc27b5> in <module>
28
29 address = Address('Grandview', 'Westland', 'Michigan', 48186)
---> 30 street = address.get_street()
31 city = address.get_city()
32 state = address.get_state()
TypeError: get_street() missing 1 required positional argument: 'street'
get_street() missing 1 required positional argument: 'street'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question