1from collections import Iterable
2
3def iterable(obj):
4 return isinstance(obj, Iterable)
1try:
2 obj = iter(obj)
3
4 except:
5 raise TypeError("obj is not iterable")
6
7finally:
8 print ("obj is iterable")
9
10from collections import Iterable
11
12if isinstance(obj, Iterable):
13 print ("obj is iterable")
14
15else:
16 print ("obj is not iterable")