-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_function.py
More file actions
36 lines (27 loc) · 963 Bytes
/
list_function.py
File metadata and controls
36 lines (27 loc) · 963 Bytes
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
31
32
33
34
35
36
list1 = [135,462,27,2753,234]
print(list1.index(27))
if 50 in list1: # 없는 값에 대한 에러처리를 위해 if문 사용
list1.index(50)
list2 = [1,2,3] + [4,5,6] # 리스트를 합칠 때 사용
print(list2)
list1.extend([9,10,11]) #뒤에 리스트를 추가
print(list1)
list1.insert(2,999) #중간에 값을 추가
print(list1)
list1.insert(-1,9999) #맨 뒤의 배열에 추가
print(list1)
list1.insert(10000,555) #기존 리스트보다 큰값을 넣을 경우 맨 마지막에 추가 됨
print(list1)
list1.sort() #정렬
print(list1)
list1.reverse() #역정렬
print(list1)
# 값
# 2
# [1, 2, 3, 4, 5, 6]
# [135, 462, 27, 2753, 234, 9, 10, 11]
# [135, 462, 999, 27, 2753, 234, 9, 10, 11]
# [135, 462, 999, 27, 2753, 234, 9, 10, 9999, 11]
# [135, 462, 999, 27, 2753, 234, 9, 10, 9999, 11, 555]
# [9, 10, 11, 27, 135, 234, 462, 555, 999, 2753, 9999]
# [9999, 2753, 999, 555, 462, 234, 135, 27, 11, 10, 9]