Jun-07-2020, 11:21 PM
Strings in python are immutable. If you try to change them, you end up making a changed copy, not changing the original.
Therefore the
If you want to change a string in a function, you probably want to return the changes and have the caller accept them.
Therefore the
check()
function above does nothing. When you attempt to change it on line 10, it changes a copy. The m
in engine()
isn't touched.If you want to change a string in a function, you probably want to return the changes and have the caller accept them.
def check(m): if len(m) != 2: for num in m: m = "0" + str(m) return m m = check(m)