Merhaba. Burada product yerine neden listeyi ekrana yazdırmış?
Bu mantık gerçekten kafamı karıştırıyor ya. Mentör nereden ayarlayabilirim kendime?
class Product:
def __init__(self, id, name, price, amount, date, is_active):
self.Id = id
self.Name = name
self.Price = price
self.Amount = amount
self.Date = date
self.Status = is_active
product_list = [
Product(1, "iPhone 13", 1500, 20, "2024-04-22", False),
Product(2, "iPhone 14", 1500, 20, "2024-04-22", True),
Product(3, "iPhone 14 Pro", 1500, 20, "2024-04-22", False),
Product(4, "iPhone 15", 1500, 20, "2024-04-22", True),
Product(5, "iPhone 15 Pro Plus", 1500, 20, "2024-04-22", False)
]
def showProducts(product_list):
active_products = []
for product in product_list:
if product.Status:
active_products.append(product)
if not active_products:
print('There is no result.')
else:
for product in active_products:
print(product.Name)
showProducts(product_list)