Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge | The for Loop
course content

Course Content

Python Loops Tutorial

ChallengeChallenge

Task

You need to update the provided products_list. If a product's price is greater than $30, apply a 25% discount.

  1. Configure the for loop to iterate through products_list.
  2. Establish the condition: If the price exceeds $30.
  3. Utilize list.append(element) to add an element to the upd_list.
  4. Apply a 25% discount to an element (price) if the price exceeds $30 by multiplying it by 0.75.
  5. Employ round(element, value) to round the price to the nearest cent.
  6. If an element is $30 or lower (the else part), add it to the upd_list without a discount.
  7. Print the updated list.

Everything was clear?

Section 1. Chapter 9
toggle bottom row
course content

Course Content

Python Loops Tutorial

ChallengeChallenge

Task

You need to update the provided products_list. If a product's price is greater than $30, apply a 25% discount.

  1. Configure the for loop to iterate through products_list.
  2. Establish the condition: If the price exceeds $30.
  3. Utilize list.append(element) to add an element to the upd_list.
  4. Apply a 25% discount to an element (price) if the price exceeds $30 by multiplying it by 0.75.
  5. Employ round(element, value) to round the price to the nearest cent.
  6. If an element is $30 or lower (the else part), add it to the upd_list without a discount.
  7. Print the updated list.

Everything was clear?

Section 1. Chapter 9
toggle bottom row
some-alt