+ 6
Help to sum(Lists, Integers, Tuples)
Is there any way to sum(Lists, Integers, Tuples) instead of using Python Built-In Functions such as isinstance()? Please see the code below to understand exactly what I mean.. https://code.sololearn.com/c1j39Q8KNNpp/?ref=app
2 Answers
+ 6
Tibor Santa
Like always, you are really helpful.
You don't know how much you've helped me to solve my problem
I canât thank you enough for this đđ
+ 4
Your code is quite intriguing, so I did some research.
Apparently according to Stackoverflow (link in my code), testing with type and isinstance is not very pythonic, and the preferred way is "duck typing", basically check if something acts like an iterable, then it MUST be an iterable. It was quite fun to refactor your code using this principle. đ
https://code.sololearn.com/cWCzqsk3MwsT/?ref=app