On Sun, Mar 31, 2013 at 12:51 PM, Soliman, Yasmin <ysoli...@uncc.edu> wrote: > yes, your program does work. The problem is if I run that similar statment in > my program, say I enter the year and for month I write Quit, it says quit is > not defined. I suppose in this senerio I would have to use the sys.exit()?
Do you mean that you want to quit if *any* of your inputs is given as 'Quit' ? The something like this should work: import weekday_string1 while True: ryear = raw_input("year= ") print ryear if ryear=='Quit': print '\nThank you for using this program! Bye.' break else: year = int(ryear) month = raw_input("month= ") day = raw_input("day= ") if month=='Quit' or day == 'Quit': break wd = weekday_string1.weekday_string(year, int(month), int(day)) print "The given date: %2d/%2d/%4d is a %s." % (month, day, year, wd) print "======================================" Couple of things here: 1. I have used raw_input() to take the input for month and day as well (Why? See the differences between input() and raw_input(): http://echorand.me/2012/10/11/input-and-raw_input-in-python/) 2. Since raw_input() returns its input as a string, I use the int() function when I call your weekday_string() function with month and date. Does that help? -Amit. -- http://amitsaha.github.com/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor