On 06Jun2014 19:00, Glen Chan <gchan...@msn.com> wrote:
Hello I am a student trying to figure out this program. Here is my objective 
and program below. What am I doing wrong? I can't get this to work.

Hi Glen,

First, please configure your mailer to send plain text instead of HTML. It works better for everyone, especially with program code.

Next, what does it do? You've supplied the requirements, fairly obviously a homework or tutorial exercise.

However, you need to describe what you expected your program to do, and what it appears to do instead. Always try to include the output of the failing run so that people can look at it and make suggestions.

Meanwhile, I'll make a few remarks about the program itself, inline below.

def main():
 endProgram = 'no'

"endProgram" looks like a Boolean variable. Use a Boolean value with it:

  endProgram = False

 print
 while endProgram == 'no':

And if you set endProgram as above, you can write this as:

    while not endProgram:

   option = 0
   print
   print 'Enter 1 to enter in new data and
store to file'
   print 'Enter 2 to display data from the
file'
   option = input('Enter now ->')

Based on the "print" statements above, I'm presuming you are using Python 2.

Don't use "input", use "raw_input". "input" treats the input as a Python expression, and can do all sorts of horrible and dangerous things.

Instead, if "optiuon" is supposed to be an integer, do this:

  option = int(raw_input('Enter now ->'))

[...]
   endProgram = raw_input('Do you want to end program? (Enter no or yes): ')
   while not (endProgram == 'yes' or endProgram == 'no'):
     print 'Please enter a yes or no'
[...]

Based on the suggested change earlier, this loop should then be followed by:

    endProgram = (endProgram == 'yes')

to get a Boolean value for the loop control variable "endProgram".

Cheers,
Cameron Simpson <c...@zip.com.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to