On 9/20/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "Boykie Mackay" <[EMAIL PROTECTED]> wrote > > >I have tried the code and it does give a syntax error.Another lesson > >for > > me I guess.I should test code before posting,unless I'm sure of my > > post. > > It's a good idea, but don't worry about it. I've been caught out a few > times myself. > > Alan G > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
I've tested the following with Python 2.4 running on GNU/Linux, and it seems to work fine. I believe I had to add a closing parens somewhere, and also added another input at the bottom so it would loop again so I could type 'quit' or 'details'. #!/usr/bin/env python # This is pyFinances v0.2 menu = """ To use this program, type 'details' to enter your details and 'quit' to quit the program. """ financeLogs = {} options = raw_input((menu)) while options != 'quit': if options == 'details': financeLogs['n_rate'] = float(raw_input("Hourly rate: ")) financeLogs['o_rate'] = float(raw_input("By which sum is your rate multiplied for overtime hours? ")) financeLogs['n_hours'] = float(raw_input("Normal hours to work: ")) financeLogs['o_hours'] = float(raw_input("Overtime hours to work: ")) financeLogs['month'] = raw_input("For which month are you due payment? ") financeLogs['rates'] = financeLogs['n_rate'] * financeLogs['o_rate'] financeLogs['total'] = (financeLogs['n_rate']) * (financeLogs['n_hours']) + (financeLogs['o_rate'] * financeLogs['o_hours']) print "Your expected earnings for %s is %d" % (financeLogs['month'], financeLogs['total']) options = raw_input((menu)) Now he needs to add a way to save the details to a file, and open the file to edit the details. If I'm not mistaken, since the details are in dictionary form, a 'pickle' is called for? =) -- bhaaluu at gmail dot com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor