How do we know when to reassign to a variable after performing some method to an input?
For example, for stringg = "Johnathan"
if we do stringg.split()
then we would need to reassign this, otherwise stringg
is still == "Jonathan"
However, if we have nums = [1,2,3]
and do nums.reverse()
, we don't have to reassign the latter and if we print nums
, we get [3, 2, 1]
I am quite confused as to when we need to reassign after performing an operation, and when we do not need to.