Q-3: What would the output when tup_and_list_transform((16, 7, 100, 0, 27),(84, 99, 78, 200, -7))
is called?
def tup_and_list_transform(tup1, tup2):
list_tup1 = list(tup1)
list_tup2 = list(tup2)
list_tup1.reverse()
return tuple(zip(list_tup1, list_tup2))
(0, 7, 16, 27, 100, 84, 99, 78, 200, -7)
Try again! Be careful not to sort in place of reverse. Also, by using zip, each tuple will have an element from list_tup1 and an element from list_tup2 in order.
(27, 0, 100, 7, 16, 84, 99, 78, 200, -7)
Try again! By using zip, each tuple will have an element from list_tup1 and an element from list_tup2 in order.
((0, 84), (7, 99), (16, 78), (27, 200), (100, -7))
Try again! Be careful not to sort in place of reverse.
((27, 84), (0, 99), (100, 78), (7, 200), (16, -7))
Correct! This converts the tuples to lists and reverses list_tup1 and zips list_tup1 and list_tup2 together.
The function call tup_and_list_transform((16, 7, 100, 0, 27), (84, 99, 78, 200, -7)) would cause an error because tuples are immutable.
Try again! While it's true that tuples are immutable, tuples can be changed into data types that are mutable in order to be changed (e.g., lists).