You can download this code by clicking the button below.
This code is now available for download.
This function accepts a list or dictionary as an argument and iterates over its elements or key-value pairs to print them.
Technology Stack : List, dictionary, iteration, printing
Code Type : Function
Code Difficulty : Intermediate
def aord_iterate(data):
if isinstance(data, list):
for item in data:
print(item)
elif isinstance(data, dict):
for key, value in data.items():
print(f"{key}: {value}")
else:
print(data)