Python Forum
Trouble with edX Python Final
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with edX Python Final
#4
def adding_report(report = "T"):
    total = 0
    numbers = "\nItems\n"
    print = input("Enter an integer, or 'Q'' to quit: ")
    while True: 
        int_or_q = input("Enter an integer, or 'Q' to quit: ")
        if int_or_q.isdigit():
            total += int(int_or_q) 
            if report.startswith("A"):
                numbers += int_or_q + "\n" 
        elif int_or_q.startswith("Q"):
            if report.startwith("A"):
                print(numbers + "\nTotal\n" + str(total))
            else:
                print("\nTotal\n" + str(total)) 
            break    
        if report.startswith("T"):  
            print("\nTotal\n" + str(total))       
        else:
            print(int_or_q, "is an invalid input, try again!")
            break
    adding_report(int_or_q)
    print()
adding_report('A')
adding_report('T')
note that I didn't look into your code (i.e. if it is correct and do what it is supposed to do)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Trouble with edX Python Final - by sarah_mb_sues - Jun-17-2018, 06:32 PM
RE: Trouble with edX Python Final - by buran - Jun-17-2018, 06:37 PM
RE: Trouble with edX Python Final - by buran - Jun-17-2018, 06:53 PM
RE: Trouble with edX Python Final - by buran - Jun-17-2018, 07:12 PM
RE: Trouble with edX Python Final - by ichabod801 - Jun-17-2018, 08:45 PM
RE: Trouble with edX Python Final - by snippsat - Jun-17-2018, 10:44 PM
RE: Trouble with edX Python Final - by cryomick - Jun-19-2018, 10:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python trouble #1 Cicada3301 5 2,274 Nov-17-2021, 09:35 PM
Last Post: Cicada3301
Smile Final Projet - Credit Risk Rauchvant 3 2,553 Nov-18-2020, 03:21 PM
Last Post: Rauchvant
  Help needed, stuck at the final output extricate 0 1,604 Jun-20-2020, 05:35 AM
Last Post: extricate
  Final Project (Databases, GUI, and Classes) poochenthecreator 1 1,755 Apr-27-2020, 09:58 PM
Last Post: deanhystad
  Final Project Help hyg71886 6 4,096 Feb-07-2019, 01:30 AM
Last Post: micseydel
  Final problem Truman 4 4,152 Jan-22-2018, 11:42 PM
Last Post: Truman

Forum Jump:

User Panel Messages

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