Zip - Intermediate Python Programming p.8

preview_player
Показать описание

The zip function iterates through multiple iterables, and aggregates them. Consider you have two lists, and you instead want them to be one list, where elements from the shared index are together. While simple, there are a few important notes to make when working with it!

Рекомендации по теме
Комментарии
Автор

Never knew that Python would overwrite your variable if you used it as an iterator. I could see how that would lead to a bad day of debugging.

gardnmi
Автор

I didnt know if I would use this until today when I had to write values from different lists as a row in csv. Neat tutorial!

MistaT
Автор

Update late 2018:
This bug for stored temp variable value in list compression has been resolved its been working now ....

pradyumg
Автор

oh, I think you forgot to add c into your print function at minute 2:15 :-)

AntonioAndrade
Автор

Makes me happy when i see a new tutorial !! thanks

TheSldsnake
Автор

Wow, zip is actually a tool to transpose a matrix. That's super useful!

tear
Автор

WHAT IS GOING ON EVERYBODY :D :D :D
So funny to hear that introduction every single time hahahaha

satterhenne
Автор

You can print the zip tuples without temp parameters, e.g. print(*zip(x, y), sep='\n'). Should produce the same output...

DivusMeta
Автор

The hell kinda keyboard layout are you using that you typo x as xm and y as yk :P

icedragon
Автор

what does the 0x00001Ea72... whatever part of the object mean when you print it at 2:30? is it the memory location?

AlexKazaak
Автор

you know you a geek when you wear a python jacket lol

codedummydev
Автор

Could you show us the uses of global variable?

winecheese
Автор

Hey Harrison, just wondering when you're going to show the 'yield' keyword :)

MorebitsUK
Автор

print zip(xyz)
Output: [(1, 7, 'a'), (2, 6, 'b'), (3, 2, 'c'), (4, 1, 'd')]

It is giving me list and not an object. Is this because Python 2.7.8

prasaddalavi
Автор

[print(x, y) for x, y in zip(x, y)] is not right way to print things, it'll generate unwanted list of 'None' value like ['None', 'None', 'None', 'None' ] . zip(x, y) will generate comma separeted values of tuple, so you can not use [print(x, y) for x, y in zip(x, y)], it's better to use [print(*i) for i in zip(x, y)]. Still don't use above mathod for printing anything.

nikunjparmar
Автор

t=[1, 2, 3, 4, 566, 7, 88, 9]
r=[4, 5, 6, 7, 8, 9]
xyz=zip(t, r)
print(dict(xyz))
print(list(xyz))
Output is
{1: 4, 2: 5, 3: 6, 4: 7, 566: 8, 7: 9}
[]
why is it giving the empty list as output?

ManishKumar-ipmd
Автор

I usually just do list of my lists, and index them like mylist[5][6]. I don't really see the benefit of zip, from what you presented.

kebakent
Автор

first_name = input('Enter First name: ')
last_name = input('Enter Last name: ')
middle_name = input('Enter Middle name: ')

for a, b, c in zip(first_name, middle_name, last_name):
print(a, b, c)


In this case it prints only the first letter of the input not the entire zip. need help

blazetechnogeeks
Автор

wr, no temptx by that, the cx doesn't l grex, nonerx, can sx answex anyx by anyx no matter wx

zes
Автор

Do a tutorial on how to open zip files with python code. EVERYONE PLEASE UP COMMENT THIS

ezekielivory
visit shbcf.ru