Python homework help request -
i need little input on why i'm not getting desired result code.
here's code:
def main(): seat_limit_a=300 print("enter total amount of tickets sold section a") sectiona=gettickets(0, seat_limit_a) print("the total amount of tickets sold section is",sectiona) def gettickets(ticket, seat_limit): ticket=int(input("enter:")) ticketsinvalid(ticket, seat_limit) return ticket def ticketsinvalid(ticket, seat_limit): while ticket <0 or ticket > seat_limit: print ("error: amount of tickets sold can't less 0 or more than",seat_limit) ticket=int(input("please enter correct amount here: ")) return ticket main()
i need number of tickets sold section in movie theater, , need validation loop verify if number entered not less or more seat limit section (in case it's a, need implement more program once figure out section). professor wants create general functions complete process section needs checked. wants main function ask sold calling gettickets function, , wants input getticket function passed on ticketsinvalid function, can checked, wants passed main function displayed.
here's output of sample test of code:
enter total amount of tickets sold section enter:400 error: amount of tickets sold can't less 0 or more 300 please enter correct amount here: 200 total amount of tickets sold section 400
i can't seem figure out how can amount entered @ validation loop display in main function correctly. without terribly altering code appreciated. complete program having pass arguments function function, that's wants... sorry long post, there's lot of bull rules wants implement. complete newbie programming, please keep in mind when write solutions/explanations :)
from method gettickets(ticket, seat_limit)
, returning old value of ticket. new value returned ticketsinvalid(ticket, seat_limit)
unused.
so make small modification in gettickets() method.
def gettickets(ticket, seat_limit): ticket=int(input("enter:")) return ticketsinvalid(ticket, seat_limit)
Comments
Post a Comment