I was reading the following example from geeksforgeeks:
# Python code to demonstrate the working of
# zip()
# initializing lists
name = [ "Manjeet", "Nikhil", "Shambhavi", "Astha" ]
roll_no = [ 4, 1, 3, 2 ]
marks = [ 40, 50, 60, 70 ]
# using zip() to map values
mapped = zip(name, roll_no, marks)
# converting values to print as set
mapped = set(mapped)
# printing resultant values
print ("The zipped result is : ",end="")
print (mapped)
but if you see the result:
The zipped result is : {('Shambhavi', 3, 60), ('Astha', 2, 70), ('Manjeet', 4, 40), ('Nikhil', 1, 50)}
I would have expected to see {('Manjeet', 4, 40), ('Nikhil', 1, 50), ('Shambhavi', 3, 60), ('Astha', 2, 70)}. So this made me thing if I want to do a mathematical operation between two lists by using zip, will zip itself change the order? I tried this little code, but it seems it doesn't, but still, I have the doubt. Did I just have luck this time or do I have to worry about it? I really need that the position of the couples in (A,B) do not change.
A = range(1,14)
B = range(2,15)
data = [x + y for x, y in zip(A, B)]
print(data)