for i in (1, 2, 3): print(i) dct = {"a": 1, "b": 2} print("Dictionary:", dct) print("Iterating over the dictionary keys:") for i in dct: print(i) print("Iterating over the dictionary values:") for i in dct.values(): print(i) print("Iterating over the dictionary keys and values:") for k, v in dct.items(): print(k, v) print(hasattr(3.14, "__iter__")) print(hasattr("pi", "__iter__")) lst = [1, 2, 3] print(type(lst)) iter_obj = iter(lst) print(type(iter_obj)) lst = [1, 2, 3] iter_obj = iter(lst) print("The iterator object length before iteration:") print(len(list(iter_obj))) for i in iter_obj: pass print("The iterator object length after iteration:") print(len(list(iter_obj))) lst = ["a", "b", "c", "d"] s = {"a", "b", "c", "d"} print(lst) print(s) lst = ["a", "b", "c", "d"] # Access the 1st item of the list. print(lst[0]) # Access the 2nd and 3rd items of the list. print(lst[1:3]) # Modify the 1st item. lst[0] = "A" print(lst[0]) dct = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5} print(dct["b"]) dct = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5} # Access the value of the 1st key in the dictionary. print(list(dct.values())[0]) # Access the values of the 2nd to 4th keys in the dictionary. print(list(dct.values())[1:4]) # Access the 2nd to 4th keys in the dictionary. print(list(dct.keys())[1:4]) lst_2 = [[1, 2, 3], {1, 2, 3}, 10] print(lst_2[0][2]) tpl = ([1, 2], "a", "b") print(tpl) # Access the 1st item of the tuple. print(tpl[0]) # Access the 1st item of the list. print(tpl[0][0]) # Modify the 1st item of the list. tpl[0][0] = 10 print(tpl)