Zip Function - Python Quick Tips
Skills:
Algorithm Basics80%
Key Takeaways
This video demonstrates the use of the zip function in Python, which allows you to combine and "zip" iterable objects together into tuples, making it useful for creating lists of paired items.
Full Transcript
in this Python quick tips video we'll be talking about these sip function and before I talk about that I want to quickly introduce a problem that the zip function can help us solve so let's say for example we have two lists x and y now they can contain a different amount of elements that doesn't matter what I want to do is loop through them and find the elements that are the same and find the elements that are different at the same index so essentially since this 9 here is an extra element we won't bother with that so what I'm gonna do to do that without my knowledge of the zip function is I'm gonna take the minimum length of x and y and loop through that using a variable I now what I'll do is I'll check if the value at X I is the same as the value of y I and if it is I'll print out same otherwise I will print out not same now when I run this we get an output that looks something like this same as 1 1 not same 2 1 same and so on now this is kind of tedious and there must be a better way to do something like this and there is and that is called B zip function so we can actually avoid this entire mess of a for loop by using zip now what zip does and I'll show you without the for loop first is it takes any amount of iterable objects and packs them together into tuples now some of you're telling me it's called tuples as well either way that's just the way I pronounce it doesn't really matter what I'm gonna do is I'm gonna take the list of zip of x and y and just show you what this looks like so when I print this you can see we get a list of tuples here we have 1 1 2 1 3 3 4 7 essentially what this does is matches up items in the list so 1 goes to 1 2 goes with 1 3 3 4 7 and then we will omit any other items now if I do this the other way so Y X this will still work will get pretty much the same thing just with the y coordinate first and the x coordinate second and notice we're not including the 9 now we can do multiple elements in this as well I can do something like Z equals and we could do you know like 1 2 like this and now if we throws that into here what we're gonna get is well a list of three tuples but this time since there's like two elements and Zed we're only gonna get two tuples here so how can we use this knowledge now the zip function to help save us some time in that previous problem so I'm gonna get rid of Zed here and I'm gonna do this now with zip so what I'm gonna do is say for I G in zip X Y if I equals equals J print same yes we'll do a capital here and then otherwise so else we will print not say okay so there we go so let's run this nap and we get the same output same not same same not same so essentially we're looping through these tuples that we built here so x and y is signing i to the first one j to the second one then we're checking if those values the same printing same otherwise we were printing not same so this is very useful this can save us a lot of time and if you're trying to create combinations of items from a turrible objects like lists zip can definitely help you out with that so anyways this has been Python quick tips on zip this is very useful you're gonna use a lot in for loops maybe in wild loops as well so get comfortable with how this works and try to think about the way that you can implement solutions using this because often it will save you a lot of time and result in you not having to build an entirely new list by yourself
Original Description
This python quick tips videos shows how to use the zip function in python. The zip function allows you to combine and "zip" iterable objects together into tuples. It is extremely useful for creating list of paired items.
Let me know what else you want to see from python quick tips!
Playlist: https://www.youtube.com/watch?v=MIqvaX_Q0c8&list=PLzMcBGfZo4-kl1reiBsCHsxQS19CyB7Ne
◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python
https://tech-with-tim.teachable.com/p...
📸 Instagram: https://www.instagram.com/tech_with_tim
🌎 Website https://techwithtim.net
📱 Twitter: https://twitter.com/TechWithTimm
⭐ Discord: https://discord.gg/pr2k55t
📝 LinkedIn: https://www.linkedin.com/in/tim-rusci...
📂 GitHub: https://github.com/techwithtim
🔊 Podcast: https://anchor.fm/tech-with-tim
💵 One-Time Donations: https://www.paypal.com/donate/?token=...
💰 Patreon: https://www.patreon.com/techwithtim
◾◾◾◾◾◾
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
Tags:
- Tech With Tim
- Python Tutorials
- Zip function
- Zip python
- Python Zip function
- Python Quick Tips
#Python #PythonQuickTips #Zip
Playlist
Uploads from Tech With Tim · Tech With Tim · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
A* Path Finding Algorithm(Visualization)
Tech With Tim
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
Python Programming Tutorial #3 - Conditions
Tech With Tim
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
Python Programming Tutorial #6 - For Loops
Tech With Tim
Python Programming Tutorial #7 - While Loops
Tech With Tim
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
Python Programming Tutorial #10 - String Methods
Tech With Tim
How to Overclock a NVIDIA GPU
Tech With Tim
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
Python Programming Tutorial #12 - Functions
Tech With Tim
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
Cool VBS Script to Prank Your Friends!
Tech With Tim
How to Overclock an AMD GPU
Tech With Tim
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
Recursion and Memoization Tutorial Python
Tech With Tim
Ethereum Mining Rig - Hardware Guide
Tech With Tim
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
How to Install Pygame (Windows 8/10)
Tech With Tim
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
Linear Search Algorithm - Python Example and Code
Tech With Tim
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
Binary Search Algorithm - Python Example & Code
Tech With Tim
Pygame Tutorial #5 - Projectiles
Tech With Tim
Pygame Game - Mini Golf
Tech With Tim
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
Pygame Tutorial #6 - Enemies
Tech With Tim
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
How to Create A Message Box in Python - Tkinter
Tech With Tim
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim
More on: Algorithm Basics
View skill →Related Reads
📰
📰
📰
📰
Understanding Algorithm Running Time
Medium · Programming
Common Methods to Find GCD
Medium · Programming
Recursion vs Iteration: Choosing Your Path Like Neo in *The Matrix*
Dev.to · Timevolt
You Don’t Need to Solve 500 LeetCode Problems. You Need to Recognize 12 Patterns.
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI