![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
def duplicateList(list):
for i in list:
print i,i
def duplicateList(string):
mylist=[]
for i in string:
mylist=mylist+[i]+[i]
return mylist
| Amelia, it works perfectly! |
| Mark Guzdial |
| No – an "item" in the list. (It doesn't actually take a string as input.) Mark Guzdial |
| Things delimeted by [] are lists. Things delimeted with () are inputs, or "tuples" (which we don't discuss in this class). This program will work for tuples or lists, but that's not always true – lists can do things that tuples can't. Mark Guzdial |