Python/ Sequence Type (list, dictionary)
Sequence Type(열거형)
1) list
- 많은 값을 하나의 list에 저장해보자
days = ["Mon","Tue","Wed","Thur","Fri"]
print("Mon" in days) = True
print(days[3]) = Thur
len(days) = 5
- 다양한 타입 저장 가능
something =["tnjkd", True, 12, None]
- mutable(변경 가능)
days.append("Sat")
["Mon","Tue","Wed","Thur","Fri", "Sat"]
2) tuple
days = ("Mon","Tue","Wed","Thur","Fri")
- immutable
3) Dictionary
- key : value 로 이루어진 Mapping 타입이다.
- nico = {
"name": "Nico",
"age": 29,
"Korean": True,
"fav_food": ["Kimchi", "Sashimi"]
}
- print(nico["name"])=Nico
- 새로운 값을 추가하고 싶을 때
nico["handsome"] = True
- Mutable
참고 예제
people = [
{'name':'jun', 'age':30},
{'name':'jun', 'age':30},
{'name':'jun', 'age':30},
]
**Python 문서
The Python Standard Library — Python 3.9.1 documentation
The Python Standard Library While The Python Language Reference describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It also describes some of the opt
docs.python.org
**