Объект не добавляется к списку
Есть 2 класса: Smartphone и review (смартфон может иметь много отзывов).
Пытаюсь добавить review методом append в конец списка, и не получаю ничего.
class Smartphone:
reviews = []
def __init__(self, imageURL, url, name, brand, rating, specifications, expSpecifications):
self.imageURL = imageURL
self.url = url
self.name = name
self.brand = brand
self.rating = rating
self.specifications = specifications
self.expSpecifications = expSpecifications
def addReview(self, singleReview):
self.reviews.append(singleReview)
def printReviews(self):
i = 0
if len(self.reviews) > 0:
while i < len(self.reviews):
print(self.reviews)
i += 1
else:
return
class review:
def __init__(self, rating, author, date, commentary, usefulCount):
self.rating = rating
self.author = author
self.date = date
self.commentary = commentary
self.usefulCount = usefulCount
def printReview(self):
print(self.rating)
print(self.date)
print(self.author)
print(self.commentary)
print(self.usefulCount)
Main:
class Main:
@staticmethod
def main():
pass
firstTry = review(5, "gay", "19022019", "only 4 gays", "1355 of 2000")
samsungGalaxy10 = Smartphone("http:image.png", "http:smartphonePage.com", "A10", "Samsung", "5", "techicalCharacteristics", "extendedTC")
samsungGalaxy10.addReview(firstTry)
samsungGalaxy10.printReviews()
Показывает пустой список. Однако, когда вручную заполняешь список reviews = ["dd", "tt"] и т.п., то все прекрасно показывается.