I am trying to loop through a list and make a variable that contains the list + some other info to be able to use it outside the for loop, however when I print my variable outside the loop I only get the last item in the list. I want to see all of them in the list.
#!/usr/bin/python
a = ['apple', 'orange', 'peanut']
for item in a:
mylist = '*' + item
print item
print "------out of loop ----------"
print mylist
The output is:
apple
orange
peanut
------out of loop ----------
*peanut