+ 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 odpowiedzi
+ 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