Course Content
Python Loops Tutorial
Python Loops Tutorial
Challenge (del)
Swipe to show code editor
You need to update the provided products_list
. If a product's price is greater than $30, apply a 25% discount.
- Configure the
for
loop to iterate throughproducts_list
. - Establish the condition: If the price exceeds $30.
- Utilize
list.append(element)
to add an element to theupd_list
. - Apply a 25% discount to an element (price) if the price exceeds $30 by multiplying it by
0.75
. - Employ
round(element, value)
to round the price to the nearest cent. - If an element is $30 or lower (the
else
part), add it to theupd_list
without a discount. - Print the updated list.
Thanks for your feedback!
Challenge (del)
Swipe to show code editor
You need to update the provided products_list
. If a product's price is greater than $30, apply a 25% discount.
- Configure the
for
loop to iterate throughproducts_list
. - Establish the condition: If the price exceeds $30.
- Utilize
list.append(element)
to add an element to theupd_list
. - Apply a 25% discount to an element (price) if the price exceeds $30 by multiplying it by
0.75
. - Employ
round(element, value)
to round the price to the nearest cent. - If an element is $30 or lower (the
else
part), add it to theupd_list
without a discount. - Print the updated list.
Thanks for your feedback!