Given:
first_list = [2, 3, 4, 5, 6, 7, 8] second_list = [4, 9, 16, 25, 36, 49, 64]
Expected Output:
Result is {(6, 36), (8, 64), (4, 16), (5, 25), (3, 9), (7, 49), (2, 4)}
Hint:
Use the zip() function. This function takes two or more iterables (like list, dict, string), aggregates them in a tuple, and returns it.
zip()
Solution:
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)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use the
zip()
function. This function takes two or more iterables (like list, dict, string), aggregates them in a tuple, and returns it.Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer