Python #list for super beginners

environment windows7 (I want a Mac Book Pro 16inch) Visual Studio Code chrome python ver3.8.3

This article is written for beginners in programming and Python.

List (array)

A list is a thing that puts values (numerical values, character strings) in a box. How to make that box (list) is the square brackets [] in Python. I will put a value (numerical value, character string) in this [].

list.py


[1,2,3,4,5]

['peach','princess','kuppa','mario']

In this way, each value is put in a delimiter (list) with (comma).

Just creating a box (list) will not work, so how to use it is as follows: variable Use with.

list.py


num_list=[1,2,3,4,5]

mmaker=['peach','princess','kuppa','mario']

print(num_list)
#[1, 2, 3, 4, 5]

print(mmaker)
#['peach', 'princess', 'kuppa', 'mario']

Multiple list

You can put another box (list) in the box (list). This is called a multiple list. Creating a multiple list is intuitive and easy. I will make another [] in [].

list.py


['peach', 'princess', 'kuppa',[1, 2, 3, 4, 5], 'mario']

One thing to keep in mind is that you should not forget to write , before and after the newly added []. Example: Variable name = [1,2,3, [9,8,7], 4,5,6].

list.py


mmaker_num = ["peach", "princess", "kuppa", [1, 2, 3, 4, 5], "mario"]

print(mmaker_num)
#['peach', 'princess', 'kuppa', [1, 2, 3, 4, 5], 'mario']

A little application

Boxes (lists) can be used in various ways, but you can also specify the value assigned to a variable as an element. What I'm saying is as follows.

list.py


x='mario'
p='peach'

hero=[x,p]

print(hero)
#['mario', 'peach']

Even if the value assigned to the variable is disturbed (changed) on the way, the value in the box (list) does not change.

list.py


x='mario'
p='peach'

hero=[x,p]

print(hero)
#['mario', 'peach']

x='luigi'
print(hero)
#['mario', 'peach']

fin

table of contents

Python #Hello World for super beginners

Python for super beginners and super beginners # Easy to get confused

Python #type (type) and how to check type (type) for super beginners of Python

How to convert Python # type for Python super beginners: str edition

How to convert Python # type for Python super beginners: int, float edition

Read Python # .txt file for super beginners in Python with working .py

Python #Function 1 for Python Super Beginners

Python #Function 2 for super beginners of Python

[Python #len function for super beginners of Python] (https://qiita.com/Macchino5/items/a64347f9e832406d3c24)

Recommended Posts

Python #list for super beginners
Python #function 2 for super beginners
Python for super beginners Python #functions 1
Python for super beginners Python # dictionary type 1 for super beginners
Python #index for super beginners, slices
Python #len function for super beginners
Python #Hello World for super beginners
Python for super beginners Python # dictionary type 2 for super beginners
python textbook for beginners
OpenCV for Python beginners
Python for super beginners Python for super beginners # Easy to get angry
Easy understanding of Python for & arrays (for super beginners)
About Python external module import <For super beginners>
Python list, for statement, dictionary
Learning flow for Python beginners
Basic Python grammar for beginners
100 Pandas knocks for Python beginners
[Python / PyQ] 4. list, for statement
~ Tips for beginners to Python ③ ~
How to convert Python # type for Python super beginners: str
[Python] list
Python # How to check type and type for super beginners
Python Exercise for Beginners # 2 [for Statement / While Statement]
<For beginners> python library <For machine learning>
Beginners use Python for web scraping (1)
[Python] Reasons for overriding using super ()
Run unittests in Python (for beginners)
Beginners use Python for web scraping (4) ―― 1
How to convert Python # type for Python super beginners: int, float
2016-10-30 else for Python3> for:
python [for myself]
Python basics: list
INSERT into MySQL with Python [For beginners]
[Kaggle for super beginners] Titanic (Logistic regression)
[Python] Minutes of study meeting for beginners (7/15)
Roadmap for beginners
[Linux command summary] Command list [Must-see for beginners]
[Python] Read images with OpenCV (for beginners)
WebApi creation with Python (CRUD creation) For beginners
Beginners practice Python
Python beginner's note
Atcoder standard input set for beginners (python)
Python list manipulation
[For beginners] Try web scraping with Python
A textbook for beginners made by Python beginners
Memo # 4 for Python beginners to read "Detailed Python Grammar"
[Linux command] cp command option list [Must-see for beginners]
[Linux command] ls command option list [Must-see for beginners]
The fastest way for beginners to master Python
[Linux command] touch command option list [Must-see for beginners]
[Linux command] cat command option list [Must-see for beginners]
Causal reasoning and causal search with Python (for beginners)
For new students (Recommended efforts for Python beginners Part 1)
Memo # 1 for Python beginners to read "Detailed Python Grammar"
[Linux command] pwd command option list [Must-see for beginners]
~ Tips for Python beginners from Pythonista with love ① ~
[Linux command] rm command option list [Must-see for beginners]
[Linux command] mv command option list [Must-see for beginners]
[Linux command] ssh command option list [Must-see for beginners]
Memo # 7 for Python beginners to read "Detailed Python Grammar"
Introduction to Programming (Python) TA Tendency for beginners