27
loading...
This website collects cookies to deliver better user experience
lists_example = [1, 2, 3, 4, 5]
tuple_example = (1, 2, 3)
sets_example = {1, 2, 3}
student_names = ["Alex", "Murphy", "Jinny", "George"]
student_ids = [700405, 700465, 700487, 700502]
for i in range(len(student_names)):
print("ID: {0} name: {1}".format(student_ids[i], student_names[i]))
final_result = list(zip(student_ids, student_names))
[(700405, 'Alex'), (700465, 'Murphy'), (700487, 'Jinny'), (700502, 'George')]
list_to_unzip = [(700405, 'Alex'), (700465, 'Murphy'), (700487, 'Jinny'), (700502, 'George')]
unzipped = zip(*list_to_unzip)
[(700405, 700465, 700487, 700502), ('Alex', 'Murphy', 'Jinny', 'George')]