Currently I'm doing the Google Foobar challenges, and I've run into a very odd issue that I'm having difficulty troubleshooting, due to the lack of detailed error reporting in Google's Foobar interface. Don't worry, nothing is given away from the problem here. Also, I have almost never used python before. The last couple days have been my first experience with it. I have had experience in Swift (not app development but general use) and Java.
And the end of a function I've written, I need to convert a concatenated list, lets call it combined_ints
, of integers into a final single integer for returning. Every single time I do the final step of converting the string made from combined_ints
, it gives me a TypeError. Due to it being Google Foobar, that's all it says. I cannot recreate this problem myself in any version of python, including 2.7.6 exactly. Example of the problem:
#list 1 2 3 arbitrarily appended ints prior
combined_ints = list1 + list2 + list3
final_str = ''.join(map(str, combined_ints))
return int(final_str) #TypeError here
Now what's super odd, is if I don't use a concatenated list here, but instead a list that was initialized and never changed, I don't get a TypeError. I have tried advice given in this thread about list of ints -> 1 number, this thread about converting strings to ints, and a couple more that I've since closed. Because I cannot manage to recreate my problem anywhere, even by just copying any pasting the exact same code from google foobar into a python 2.7.6 interpreter, I am at a complete loss. I need to return an int. I hope this isn't a stupid error on my end, or Google's end.