Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
The purchases made by a customer in a year are stored in a list. You are required to count the number of purchases that exceeds $100.

Rearrange the code in the correct sequence to form a function that receives a list of numbers representing the purchase amount per month and counts the number of times
that the purchase amount is 100 or more. The total number of times is returned by the function.

Python
1 def num_purchase(monthly_amounts):
2 count = 0
3 if amount >=100
4 return count


What I have tried:

I tried this, but it seems wrong 1-3-2-4.
Posted
Updated 6-May-22 9:16am
v6

Every rearrangement of such a code is doomed to fail, because the sequence is incomplete.
You are going to rearrange and complete it, in order to obtain a working function.
 
Share this answer
 
Think about how you can inspect every item in a list: 5. Data Structures — Python 3.10.4 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900