a = ['주원', '세준', '재원', '종민']
a.pop()
a.pop(1)
print(a.pop(0))
print(a)

seq = [1, 1, 1, 2, 2, 3]
print(seq.count(1))

str1 = "ialikeapython"
print(str1.split('a'))
str2 = "1 2 3 4 5"
print(str2.split(' '))

dessert = ['coffee', 'cake']
print('&'.join(dessert))
dessert2 = ['ice', 'cream']
print(''.join(dessert2))

#튜플
(1,)
('a', 'b', 'c')
tuple1 = (1, 2, 3, 4, 5)
print(tuple1[2]) #인덱싱
print(tuple1[2:4]) #슬라이싱

tuple2 = ('a','l','g','o')
print('o' in tuple2) #원소 조회 가능
print(len(tuple2)) #길이 확인 가능
print(tuple2 * 2) #곱하기 연산
print(tuple2 + tuple1) #더하기 연산

#튜플은 원소 추가, 삭제, 변경이 불가능하다.

#딕셔너리
#{key1: value1, key2: value2}
person = {'name': '김알고', 'age':10, 'school':'가고파초등학교'}
print(person['name'])
person["address"] = '양덕동' #딕셔너리의 추가
del person['age'] #딕셔너리의 삭제
print(person)

#딕셔너리의 key는 바뀔 수 없다!
#dict = {[1, 2, 3]:'num'} 리스트는 값이 바뀌기 때문에 에러가 난다.
dict = {(1, 2, 3): 'num'} #key가 튜플이면 값이 바뀌지 않아서 정상작동한다.
print(dict)





Embed on website

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