Skip to content

Instantly share code, notes, and snippets.

@macloo
Last active December 31, 2015 15:39
Show Gist options
  • Save macloo/8008820 to your computer and use it in GitHub Desktop.
Save macloo/8008820 to your computer and use it in GitHub Desktop.
Introductory script for adding items to a list in Python.
# some things we do with lists
userlist = [] # makes an empty list
q = "n"
x = "a"
while q == "n":
e = raw_input("Add an element: ")
userlist.append(e)
q = raw_input ("Do you want to quit? (y/n) > ")
print "\nThis is your list:"
print userlist
print '''\nNow, a new list. When you're done, type \"stop.\" '''
nextlist = [] # makes an empty list
while x != "stop":
x = raw_input("Add an element: ")
nextlist.append(x)
print "\nThis is your new list:"
print nextlist
print "\nThis is your old list:"
print userlist, "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment