Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
more
Archives
Today
Total
관리 메뉴

꼬물꼬물 개발자

list, tuples, dictionary 본문

Python

list, tuples, dictionary

한고운 2024. 8. 31. 04:28
# 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