first_list = [2, 3, 4, 5, 6, 7, 8] second_list = [4, 9, 16, 25, 36, 49, 64]
Result is {(6, 36), (8, 64), (4, 16), (5, 25), (3, 9), (7, 49), (2, 4)}
Use the zip() function. This function takes two or more iterables (like list, dict, string), aggregates them in a tuple, and returns it.
first_list = [2, 3, 4, 5, 6, 7, 8]
print("First List ", first_list)
second_list = [4, 9, 16, 25, 36, 49, 64]
print("Second List ", second_list)
result = zip(first_list, second_list)
result_set = set(result)
print(result_set)
First List [2, 3, 4, 5, 6, 7, 8]
Second List [4, 9, 16, 25, 36, 49, 64]
{(6, 36), (8, 64), (4, 16), (5, 25), (3, 9), (7, 49), (2, 4)}
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.
Sign in to save your progress and continue exactly where you left off.