Python--Initializing variables using a variable in the current parameter -
i find myself assigning variable none
in variable assignment, , wondering if there more efficient , less ugly way.
def stringlength(string = "hello", slength = none): if slength == none: slength = len(string)
here example. want assign slength
length of string
. how can in more efficient way?
i doing because using permutation code, recall using same method, please don't comment saying write variable later on :d
the possible improvement have replace slength == none
slength none
. latter more accurate, , perhaps more efficient.
Comments
Post a Comment