DEV Community

loading...

Discussion on: Python Zero to Hero #Beginners⚡

Collapse
zacland profile image
Zac

Hi !
I think there is an error in section "Mutable objects"

lists are mutable in python

color = ["red", "blue", "green"]
print(color)
["red", "blue", "green"]
color[0] = "pink"
color[-1] = "orange"
print(color)
["red", "blue", "green", "orange" ]


I think, the final result is :
['pink', 'blue', 'orange']

No ?! :D

Collapse
vivekcodes profile image
vivek patel Author

Read my words again i mentioned that lists are mutable in python!

Collapse
zacland profile image
Zac

No doubt on what you say :)
I just tell you : If i write your example line by line, the final result is false :D

Thread Thread
vivekcodes profile image
vivek patel Author

Thanks 😊 I've added one photo for better understanding😃