On 23/08/12 18:02, Ashley Fowler wrote:

def main():
     l = list()
     x = eval(input('Enter a number: '))

Don;t use eval() its bad practicecand fort advanced use only.
Instead explicitly convert to int() or float()

     while x >= 0:
         l.append(x)
         x = eval(input('Enter a number: '))

Same here.


     ask = input (" Do you want to perform a list operation?")
     if "yes":

You need to test if ask is equal to 'yes'
Testing 'yes' directly will always be true because 'yes' always exists.

         input (" Do you want to test, peek, add, or remove?")

you need to store the reurn value from input as you did above

         if "test":

and use that stored value in the test.

             if not l:
                 print("The list is not empty")
             else:
                 print("The list is empty")

HTH


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to