python - Converting a list of Strings into one single integer -
i have list one:
["1", "8", "9", "5", "6"] and want convert single integer. desired output this: 18956
is there elegant method this?
the way coming mind going through list , multiplying digit needed power of ten , adding up. sure there better method, not it? help.
this want:
it joins each digit single string using '' (an empty string) separator, yielding '18956'.
it converts string integer using int() factory function:
int(''.join(["1", "8", "9", "5", "6"]))
Comments
Post a Comment