Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loops maybe
#3
print (" How many items do you have?")
numberofitems = input()
total = 0 
for item in range(numberofitems):
    x = float(input('Enter the price £: '))
    total = total + x
#now print out the total in a nice format
This creates a loop that asks for the price of each object, you will then need to add the code for formatting the sum (total)
Reply


Messages In This Thread
Loops maybe - by gray1306 - Nov-30-2019, 08:41 PM
RE: Loops maybe - by DreamingInsanity - Nov-30-2019, 08:52 PM
RE: Loops maybe - by jefsummers - Dec-02-2019, 02:58 AM
RE: Loops maybe - by DreamingInsanity - Dec-02-2019, 10:10 AM
RE: Loops maybe - by perfringo - Dec-02-2019, 10:47 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020