Answers for "how to see if object is iterable in c@"

0

how to check if an object is iterable in python

try:
  obj = iter(obj)
  
 except:
  raise TypeError("obj is not iterable")
  
finally:
  print ("obj is iterable")
  
from collections import Iterable

if isinstance(obj, Iterable):
  print ("obj is iterable")
  
else:
  print ("obj is not iterable")
Posted by: Guest on March-28-2020

Code answers related to "how to see if object is iterable in c@"

Python Answers by Framework

Browse Popular Code Answers by Language