Last active
December 31, 2015 15:39
-
-
Save macloo/8008820 to your computer and use it in GitHub Desktop.
Introductory script for adding items to a list in Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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