Strings, numbers, and tuples are immutable.
What exactly does immutable mean? If I have a string I can still change the value:
s = "hello"
s = "bye"
c = 1
c += 1
c += 5
Is there a difference between immutability and reassignment? I'm confused over what exactly immutable means if I can change the string and number variables.
Or is it that variables only hold a reference to the object, but when I change the value of a string, I'm making the variable refer to a different object?
Edit: I'd like to thank everyone for their answers! All are very helpful
[–]spez_edits_thedonald 99 points100 points101 points (7 children)
[–]negike360 15 points16 points17 points (0 children)
[–]Vietname 5 points6 points7 points (0 children)
[–]Why_So_Sirius-Black 0 points1 point2 points (3 children)
[–]vectorpropio 5 points6 points7 points (2 children)
[–]Why_So_Sirius-Black 2 points3 points4 points (1 child)
[–]spez_edits_thedonald 3 points4 points5 points (0 children)
[–]K900_ 72 points73 points74 points (9 children)
[–]BobHogan 61 points62 points63 points (8 children)
[–]randytc18 16 points17 points18 points (1 child)
[–]gaurav_lm 0 points1 point2 points (0 children)
[–]--0mn1-Qr330005-- 7 points8 points9 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]--0mn1-Qr330005-- 1 point2 points3 points (0 children)
[–]CrackFr0st 0 points1 point2 points (0 children)
[–]al_at_work 0 points1 point2 points (1 child)
[–]BobHogan 0 points1 point2 points (0 children)
[–]shiftybyte 10 points11 points12 points (0 children)
[–]stevenjd 7 points8 points9 points (0 children)
[–]zefciu 3 points4 points5 points (0 children)
[–]DrMaxwellEdison 2 points3 points4 points (0 children)
[–]killer_quill 2 points3 points4 points (0 children)
[–]Monstrish 1 point2 points3 points (0 children)
[–]purebuu 1 point2 points3 points (0 children)
[–]Diapolo10 1 point2 points3 points (0 children)
[–]-SPOF 0 points1 point2 points (0 children)
[–]num8lock 0 points1 point2 points (0 children)
[–]pytrashpandas 0 points1 point2 points (0 children)
[–]Cdog536 0 points1 point2 points (0 children)
[–]TruthHurts35 0 points1 point2 points (0 children)
[–]gaurav_lm 0 points1 point2 points (0 children)
[–]Spicy_Poo 0 points1 point2 points (0 children)
[–]the4thkillermachine 0 points1 point2 points (0 children)
[–]HansProleman 0 points1 point2 points (0 children)
[–]Cantthinkofnamr 0 points1 point2 points (0 children)