Python amateurs try to summarize the list ①

Introduction

Let's put together Python for super beginners https://qiita.com/kkhouse/items/675b846d0bcf41cd191f

Python beginners talk about how to remember this much https://qiita.com/kkhouse/items/74d7acb768e6542339ac

It is a continuation of this area. I haven't made it into a series, but I have a feeling that it will be a series. We have set a limit on the amount of time we can spend, so this time we will rush to summarize the list.

What is a list?

"1, 2, 3, 4 ...", "Hokkaido, Miyagi prefecture, Tokyo, Fukuoka prefecture ...", etc.

You can combine multiple elements. It is often more convenient for a program to store multiple elements together than to store them individually in variables.

It may be easier to understand if you understand that a box called a variable is packed with multiple elements.

As a usage

pre_name =["Hokkaido","Miyagi Prefecture","Tokyo","Fukuoka Prefecture"]

print(pre_name)

Then

["Hokkaido","Miyagi Prefecture","Tokyo","Fukuoka Prefecture"]

Is output.

How to write a list

demo_list = [element,element,element・・・]
demo_list = list(element,element,element・・・)

There are two ways. By the way,

pre_name =["Hokkaido","Miyagi Prefecture","Tokyo","Fukuoka Prefecture"]

If you want to add a new element "Osaka" to the list of, use the append () method.

pre_name =["Hokkaido","Miyagi Prefecture","Tokyo","Fukuoka Prefecture"]
pre_name.append("Osaka")
print(pre_name)
#["Hokkaido","Miyagi Prefecture","Tokyo","Fukuoka Prefecture","Osaka"]

What is a method? Representative of list method

A method is simply an additional operation. You can add operations to variables by selecting "Variable.Method".

pre_name.append("Osaka")

Is instructing to append (add) Osaka prefecture to the box (variable) called pre_name. This append is the method.

Besides

list = [1,2,3,4]
list.remove(3)
print(mylist)

#[1,2,4]

And so on, there is a remove method that you can use to remove an element from the list.

Continue

When I was a super beginner, when I understood the meaning of being able to perform additional operations with this ".method", I remember that the program became readable dramatically.

This means that if you suppress the concept from the very beginning, your ability to read the code in the future will become much stronger!

The list is basic but a little deep, so that's it for today.

See you tomorrow

Recommended Posts

Python amateurs try to summarize the list ①
A python amateur tries to summarize the list ②
Try to get the function list of Python> os package
Try to solve the man-machine chart with Python
[Algorithm x Python] How to use the list
[Cloudian # 5] Try to list the objects stored in the bucket with Python (boto3)
[Python] How to remove duplicate values from the list
Try to solve the programming challenge book with python3
[Python] Convert list to Pandas [Pandas]
[Python] Try to read the cool answer to the FizzBuzz problem
Try to understand Python self
[Python] How to use list 1
Try to solve the internship assignment problem with Python
[Introduction to Python] <list> [edit: 2020/02/22]
[Python] How to output the list values in order
I tried to summarize the string operations of Python
[Python] I tried to summarize the array, dictionary generation method, loop method, list comprehension notation
How to get the last (last) value in a list in Python
Try to decipher the garbled attachment file name with Python
Extract the value closest to a value from a Python list element
Leave the troublesome processing to Python
Try the Python LINE Pay SDK
Try to operate Facebook with Python
In the python command python points to python3.8
How to get the Python version
Convert list to DataFrame with python
Try to introduce the theme to Pelican
Try to calculate Trace in Python
Python> list> Convert double list to single list
[Python] How to import the library
Try converting cloudmonkey CLI to python3 -1
Try using the Python Cmd module
Cython to try in the shortest
The fastest way to try EfficientNet
About the basics list of Python basics
The easiest way to try PyQtGraph
[Python] Change the alphabet to numbers
Try to get a list of breaking news threads in Python.
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)
[Python] Try to graph from the image of Ring Fit [OCR]
Try python
First python ② Try to write code while examining the features of python
[Cloudian # 2] Try to display the object storage bucket in Python (boto3)
[Python] list
Try to implement and understand the segment tree step by step (python)
Try to solve the shortest path with Python + NetworkX + social data
[Python] A program that rotates the contents of the list to the left
[Introduction to Udemy Python3 + Application] 18. List methods
I tried to summarize Python exception handling
Try to reproduce color film with Python
Try logging in to qiita with Python
Try using the Wunderlist API in Python
I tried to summarize the umask command
Try to face the integration by parts
[Python] How to convert a 2D list to a 1D list
OR the List in Python (zip function)
Python3 standard input I tried to summarize
Let's summarize the Python coding standard PEP8 (1)
[Introduction to Udemy Python3 + Application] 17. List operation
[Python] Summarize the rudimentary things about multithreading
[Python] Try pydash of the Python version of lodash