you are printing the list
type. To print list1
, do:
print "list1 = ", list1
Question
I have a really simple program in Python, but it's not printing out the list in the shell.
The program is:
list1 = [20]
print "list1 = ", list
def change(alist):
alist.append(100)
change(list1)
print "list1 = ", list
When I try it in shell, I get
>>> import test
list1 = <type 'list'>
list1 = <type 'list'>
How do I print out the actual values in the list?
Solution
you are printing the list
type. To print list1
, do:
print "list1 = ", list1