Level
Find the error
-
from typing import List, Tuple
-
def calculate_total(items: List[Tuple[str, float, int]], tax_rate: float, discount: float) -> float:
-
    total: float = 0.0
-
    for item_name, price, quantity in items:
-
        item_total = price * quantity
-
        total += item_total
-
    if discount > 0:
-
        total -= total * (discount / 100)
-
    return
-
cart_items = [('Book', 15.99, 2), ('Pen', 1.50, 5)]
-
print(calculate_total(cart_items, 5, 10))

Calculate Shopping Cart Total

This code snippet involves a function to calculate the total cost of items in a shopping cart, including tax and discounts. Analyze the function for logic errors and correct type annotations in a real-world e-commerce scenario. Identify the lines with logical and syntactical errors in the context of a typical shopping cart calculation.