Why does python not support mylist being redefined to [7,7,7,7] and having it propagate back to main(). But it does support it if I were to change each index to 7 like mylist[0] = 7 would make the second print statement [7,2,3,4]
def changes(mylist):
mylist = [7,7,7,7]
def main():
mylist = [1,2,3,4]
print (mylist)
changes(mylist)
print (mylist)
main()
It would work if I used this
def changes(mylist):
for x in range(len(mylist)):
mylist[x] = 7
def main():
mylist = [1,2,3,4]
print (mylist)
changes(mylist)
print (mylist)
main()