I am working through a udemy course on Python, this is the first real program I've written. I am new to Python and to programming.
I'd like to replace the main
function below with something more efficient and less repetitive but I'm not sure what or how. The most I could think to do is write a function for adding hours and call it under each day.
Most relevant code:
def main(day):
if day == "Monday":
print "Today is %s, How many hours would you like to add today?" % (day)
hours = int(raw_input())
DOTW['Monday'] = DOTW['Monday'] + hours
print "Cool your hours for %s are %d" %(day, DOTW['Monday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
if day == "Tuesday":
print "Ah, Today is %s, How many hours have you worked?" %(day)
hours = int(raw_input())
DOTW['Tuesday'] = DOTW['Tuesday'] + hours
print "alright, yours hours for %s are %d" %(day, DOTW['Tuesday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
if day == "Wednesday":
print "Ah, Today is %s, How many hours have you worked?" %(day)
hours = int(raw_input())
DOTW['Wednesday'] = DOTW['Wednesday'] + hours
print "Cool for %s I've got %d hours" %(day, DOTW['Wednesday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
if day == "Thursday":
print "Ah, Today is %s, How many hours have you worked?" %(day)
hours = int(raw_input())
DOTW['Thursday'] = DOTW['Thursday'] + hours
print "Your hours for %s are %d" %(day, DOTW['Thursday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
if day == "Friday":
print "FINALLY IT'S FRIDAY!!! How many hours have you worked?"
hours = int(raw_input())
DOTW['Friday'] = DOTW['Firday'] + hours
print "Cool. for %s I've got %d hours" %(day, DOTW['Friday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
if day == "Saturday":
print "Ah, Today is %s, How many hours have you worked?" %(day)
hours = int(raw_input())
DOTW['Saturday'] = DOTW['Saturday'] + hours
print "alright, yours hours for %s are %d" %(day, DOTW['Saturday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
if day =="Sunday":
print "Ah, Today is %s, How many hours have you worked?" %(day)
hours = int(raw_input())
DOTW['Sunday'] = DOTW['Sunday'] + hours
print "Cool your hours for %s are %d" %(day, DOTW['Monday'])
want = raw_input("Do you want to add more time? y/n \n > ")
overtime()
leave(want)
The entire program: http://pastebin.com/8hLVcGMr