This is my first code. I would really appreciate a critique for it, if anyone can spare the time.
def wedcost(hours): print " " try: hours = int(hours) except ValueError: print "Invalid input" new_hours = raw_input("Please use only numeric characters. ") hours = int(new_hours) print " " tcost = hours * 75 # $75/hr for two shooters if hours < 4: tcost = 250 # price starts at a fixed $250 from 1 to 3 hours if hours >= 6: tcost = hours * 100 # I don't like long shifts print "The total cost of our services will be $" + str(tcost) + "." print " " def recalc(answer): # this second function is where I had the most trouble outcome = 0 # only method I could get to work properly if answer.startswith('y' or 'Y'): print " " outcome += 1 wedcost(raw_input("How long will we be on location? ")) if answer.startswith('n' or 'N'): print " " print "Have a nice day :)" outcome += 1 if outcome == 0: print "Invalid input" recalc(raw_input("Would you like to recalculate? ('Yes' or 'No') ")) # I had previously tried checking 'answer' to items in lists recalc(raw_input("Would you like to recalculate? ('Yes' or 'No') ")) wedcost(raw_input("How long will we be on location? "))
I'm sure that there's a better way to go about this task. Any suggestions or hints?