Python detect and prevent TypeError: sequence item 0 and join iterable
https://blog.softhints.com/python-det...
Errors:
* TypeError: sequence item 0: expected str instance, int found
and
* TypeError: can only join an iterable
Option 1
import collections
mylist = 2
if isinstance(mylist, collections.Iterable):
print(', '.join(mylist))
Option 2
try:
iterator = iter(mylist)
except TypeError:
print('not iterable')
else:
print(', '.join(mylist))