Language/python
python 시험 대비
물극필반99
2022. 6. 13. 13:27
반응형
1. 이중 리스트 만들기
testlist = [[ 0 for _ in range(2)] for _ range(5)]
[[0,0], [0,0], [0,0], [0,0], [0,0]]
2. List extend
testa = [1,2]
testb = [3,4]
testa.expend(testb)
print(testa)
[1,2,3,4]
3. List append
testa = [1,2]
testb = [3,4]
testa.append(testb)
print(testa)
[1,2,[3,4]]
4. List Sort
testa = [1, 3, 2, 4]
testa.sort()
print(testa)
[1, 2, 3, 4]
testa.sort(reverse = True)
print(testb)
[4, 3, 2, 1]
반응형