#리스트 다루기
#원소 추가하기 append()
a = []
a.append(3)
a.append(5)
#리스트의 가장 마지막 자리에 추가한다.
print(a)

#원소 특정 위치에 추가하기 insert()
b = [10, 30, 45, 20]
b.insert(1, 25)
print(b)

#특정 원소 삭제하기 remove()
b.remove(45)
print(b)

#리스트 원소 정렬하기 sort()
b.sort()
print(b)
c = ['banana', 'strawberry', 'apple', 'orange']
c.sort()
print(c)

#시퀀스
#원소 조회
d = "orange"
print('k' in d)
print('o' in d)

#길이 확인
e = "python"
f = ['h','e','l','l','o']
print(len(e))
print(len(f))

#연결 연산 가능
g = "on" + "ce"
print(g)

#반복 연산 가능
h = ['hi'] * 3
print(h)

fruits = ['바나나', '딸기', '두리안', '망고']
if '딸기' in fruits:
    fruits.remove('딸기')
    fruits.append('복숭아')
    print(fruits)
else:
    print("딸기가 없습니다")








Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: