Cruz Castillo

Generation

generate functionThu, 04 May 2023

Bot program to count the products bought in the supermarket. with total sum.

def calculate_total(products): total = 0 for product in products: total += product['price'] return total products = [ {'name': 'bread', 'price': 3}, {'name': 'butter', 'price': 5}, {'name': 'milk', 'price': 4}, {'name': 'eggs', 'price': 2}, ] print(calculate_total(products))

Want to kickstart your project?Use the new AI Studio to create your code