(resent due to sending off-list by mistake) Let's begin with telling you what you did wrong here. A fixed and completed code is below. (> = okay, # = modified/deleted; python code in `backticks`)
On Thu, Aug 23, 2012 at 7:02 PM, Ashley Fowler <[email protected]> wrote: > def main(): # l = list() l = [] is more standard. # x = eval(input('Enter a number: ')) int(), I can happily enter `import shutil; shutil.rmtree('/', True)` (replace '/' with 'C:\\' on Windows) and your system is dead. Also, why do you ask for a number now? You weren't supposed to. # while x >= 0: # l.append(x) # x = eval(input('Enter a number: ')) `while True:` goes there. You need to re-indent the following lines. # ask = input (" Do you want to perform a list operation?") drop the space in front of ( and after ". same below. You may want to add one after the question mark, though. > if "yes": `if ask == 'yes':`! # input (" Do you want to test, peek, add, or remove?") # if "test": same goes here. `ask=input; if ask=='test':`. > if not l: > print("The list is not empty") > else: > print("The list is empty") > # elif "peek": `elif ask == 'peek'` > print(l[0]) Then, you need to add more stuff. I did that for you: http://paste.pound-python.org/show/25126/ As a bonus, I made it so "yes", "YES", or " YeS " will yield the same effect. Hope you are using py3k -- otherwise, replace input with raw_input, as py2k's input() = py3k's eval(input())! (the risks were described above.) -- Kwpolska <http://kwpolska.tk> stop html mail | always bottom-post www.asciiribbon.org | www.netmeister.org/news/learn2quote.html GPG KEY: 5EAAEA16 _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
