[Python] list

list

** How to make a list ** [Element 1, Element 2, Element 3] Separated by ,.

List example List of strings ["sushi" , "ramen"]

List of numbers [100 , 200]

** Assign a list to a variable **

fruits = ["apple" , "banana" , "strawberry"]

** Output list, get element ** List output

fruits = ["apple" , "banana" , "strawberry"]

print(fruits)

Output result ["apple" , "banana" , "strawberry"]


Get list elements Variable [index number] Variable is a list assigned

fruits = ["apple" , "banana" , "strawberry"]

print("My favorite fruit is" + fruits[1] + "is")

Output result My favorite food is banana


** Overwriting elements ** List [index number] = value

fruits = ["apple" , "banana" , "strawberry"]

fruits[1] = "kiwi"

** Add element ** List .append (value)

fruits = ["apple" , "banana" , "strawberry"]

fruits.append("kiwi")

Recommended Posts

[Python] list
Python> Comprehension / Comprehension> List comprehension
Python list manipulation
Sorted list in Python
Python Exercise 2 --List Comprehension
List of python modules
Python> list> extend () or + =
Python
Python list comprehension speed
python unittest assertXXX list
Python3 List / dictionary memo
OpenCV3 Python API list
Python error list (Japanese)
List find in Python
Python exception class list
Initialize list with python
Python hand play (two-dimensional list)
Python list, for statement, dictionary
Summary of Python3 list operations
[Python] Convert list to Pandas [Pandas]
[Python] How to use list 1
Create ToDo List [Python Django]
Specify multiple list indexes (Python)
Python Basic Course (5 List Tuples)
Python list is not a list
[Python] Copy of multidimensional list
[Introduction to Python] <list> [edit: 2020/02/22]
Python list and tuples and commas
Python list comprehensions and generators
[Python / PyQ] 4. list, for statement
Python #list for super beginners
Getting list elements in Python
Extract multiple list duplicates in Python
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python comprehension
Python technique
Studying python
Python 2.7 Countdown
Python memorandum
Python FlowFishMaster
Difference between list () and [] in Python
[python] Manage functions in a list
Python service
List comprehension
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
linked list
Python comprehension
install python
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python Jinja2