A organisation classifies the amounts donated by the public into two different tiers:
- Tier 1: Amounts greater than or equal to $100
- Tier 2: Amounts less than $100
Write a program that can ask for the total number of donations received, as well as the donated amounts. After which, display the following for each tier:
- List of donated amounts
- Total amount
- Average amount
After the user has input the total number of donors, the while loop will print "Enter amount donated by donor (number)" until it reaches the last donor. I have no idea how to go about doing that. This is my current attempt:
donors=int(input("Enter total number of donations received: "))
tier1=[]
tier2=[]
i=0
while donors < (donors+1):
amount=int(input("Enter amount donated by donor {0}: ".format(i+1)))
if amount >=100:
tier1.append(amount)
else:
tier2.append(amount)
average1=(sum(tier1)/len(tier1))
average2=(sum(tier2)/len(tier2))
print("Tier 1 donations received is " +str(tier1))
print("Total amount for Tier 1 is {0}".format(sum(tier1)))
print("Average amount for Tier 1 is $" + str(average1))
print("Tier 1 donations received is " + str(tier2))
print("Total amount for Tier 1 is {0}".format(sum(tier2)))
print("Average amount for Tier 1 is $" + str(average2))
The output keeps printing "Enter amount donated by donor 1:" instead of
"Enter amount donated by donor 1: "
"Enter amount donated by donor 2: "
"Enter amount donated by donor 3: "