[Python] What is a zip function?

Memorandum

The zip function is used when you want to retrieve elements from different lists at the same time.

(Example 1) When using in a for statement

 for alpha, kana in zip(["a","b","c"],["Ah","I","U"]):
    print(alpha, "and", kana)

Execution result 1


a and a
b and i
c and u

(Example 2) When using in list

a = [1,2,3]
b = [11,12,13]
c = list(zip(a,b))
c

Execution result 2


[(1, 11), (2, 12), (3, 13)]

Recommended Posts

[Python] What is a zip function?
What is a callback function?
What is a python map?
[Python] What is a with statement?
What is python
What is Python
What is a dog? Python installation volume
What is a distribution?
[Python] What is Pipeline ...
What is a terminal?
What is a hacker?
What is a pointer?
[Python] What is virtualenv
Tell me what a conformal map is, Python!
Create a function in Python
What is the activation function?
What is a decision tree?
Python list is not a list
What is a Context Switch?
[Python] Python and security-① What is Python?
What is a super user?
[Python] * args ** What is kwrgs?
What is a system call
[Definition] What is a framework?
What is the Callback function?
Python Basic Course (1 What is Python)
Basics of Python learning ~ What is a string literal? ~
What is God? Make a simple chatbot with python
[Python] Make sure the received function is a user-defined function
What does the last () in a function mean in Python?
What is Python? What is it used for?
Call a Python function from p5.js.
python function ①
[Python] function
[Python] What is @? (About the decorator)
What is a lexical scope / dynamic scope?
What is a Convolutional Neural Network?
[python] What is the sorted key?
Python for statement ~ What is iterable ~
[Python] Make the function a lambda function
What is the python underscore (_) for?
python zip
Python> What is an extended slice?
How to use python zip function
python function ②
[Python] Execution time when a function is entered in a dictionary value
[Python] What is pandas Series and DataFrame?
Create a Python function decorator with Class
[Python] What is inherited by multiple inheritance?
What is NaN? NaN Zoya (Python) (394 days late)
Precautions when pickling a function in python
What kind of programming language is Python?
Python learning basics ~ What is type conversion? ~
OR the List in Python (zip function)
What is "mahjong" in the Python library? ??
What is a dog? Django installation volume
Hash in Perl is a dictionary in Python
[Introduction to Udemy Python3 + Application] 46. Zip function
[python] [meta] Is the type of python a type?
What I did with a Python array
About February 02, 2020 * This is a Python article.