as a personal exercise I am trying to create my own little zip() function that takes two lists and puts the items into a list of tuples. In other words if these are my list:
fr = [6,5,4]
tr = [7,8,9]
I would expect this:
[(6,7), (5,8), (4,9)]
Here is my code:
def zippy(x, y):
zipper = []
for i in x :
for g in y:
t = (i,g)
zipper.append(t)
What I get is: [(6, 9), (5, 9), (4, 9)],
but when I define the lists inside of the function, it works as intended. Any help is appreciated.
tthree times before you append it, meaning that the first entry in your list of tuples will be the very last value iny.