I'm new to programming and have a requirement wherein I have to iterate through the elements of an input. The input can be a string, a list (mostly) or a dict. I wrote some code to check if the given input is a string or a list or a dict etc., but I'm wondering if there is an easier way to do it.
For example, I check as follows:
 if isinstance(vlan, list):
      for i in  vlan:
          <<do some operation here>>
 if isinstance(vlan, string):
      <<do some operation here>>
 if isinstance(vlan, dict):
      for i in vlan.keys()
         <<do some operation here>>
This operation I have to carry out a lot of times (although I can write a function do expand and send the elements I'm just wondering if there is any alternate to it).