Why is the initializer=0 was used?
For example, if we have -324, we just need to have (310+2)10+4 * (-1) = ( 310**2 + 210 + 4 ) * (-1), but where does the 0 needed? (I observed “TypeError: must be str, not int”, though)
Maybe, does this put running_sum=0, c=0, initially, to make it (0*10+index(0)) … as the running_sum cannot be str, if so I get the initializer does the job of setting all the argument of lambda: function as initializer.
If so, the explanation of the Python official doc is somewhat misleading that “If the optional initializer is present, it is placed before the items of the sequence in the calculation, and [serves as a default when the sequence is empty]. If initializer is not given and sequence contains only one item, the first item is returned. (bracket is added by me for emphasis)”
Actually, it should be stated as ‘serves as a default to be run before the lambda reads the given sequence.’ This vagueness somewhat brought me confusion understanding the code. However, I learned many things out of this code. Thanks.