꼬물꼬물 개발자
list, tuples, dictionary 본문
# list
day_of_week = ["Mon", "Tue", "Wed", "Thu", "Fri"]
print(day_of_week[2])
day_of_week.append("sun")
print(day_of_week)
day_of_week.remove("sun")
print(day_of_week)
day_of_week.clear()
print(day_of_week)
# Tuples : 불변
days = ("Mon", "Tue", "Wed", "Thu", "Fri")
print(days[-1])
# dictionary : kdy - value 키-값
player = {
'name': 'gowoon',
'age': 42,
'alive': True,
'fav_food': ["피자", "햄버거"]
}
print(player)
print(player.get('fav_food'))
print(player['fav_food'])
print(player)
player.pop('age')
print(player)
player['xp'] =1500
print(player)
player['fav_food'].append("국수")
print(player.get('fav_food'))
print(player['fav_food'])
'Python' 카테고리의 다른 글
while (0) | 2024.08.30 |
---|---|
input, and, or (0) | 2024.08.29 |
if, else, elif (0) | 2024.08.23 |
Return (0) | 2024.08.22 |
Functions (0) | 2024.08.22 |