# list using '[' or ']' keyword for generating list object # but tuple use '(' or ')' keyword. And tuple is can't change elements after generated. # tuple is more faster than list # generate tuple object t = ('SAMSUNG', 'LG', 'SK') print(t) # Also tuple is use index for access elements. print(t[0]) print(t[1]) print(t[2]) # test: change element value # It will be comes up some error message. t[0..
t = ('SAMSUNG', 'LG', 'SK') # tuple use '[' or ']' keyword for slicing. # Be careful do not confuse between '(',')' and '[',']' keywords. print(t[0:2]) # if you use '(',')' keyword for slicing. error message is appeared. print(t(0: 2)) 실행결과 $ py tuple_indexing.py File "tuple_indexing.py", line 8 print(t(0: 2)) ^ SyntaxError: invalid syntax
# variable binding a memory of has some value. interset1 = "삼성전자" interset2 = "LG전자" interset3 = "네이버" interset4 = "카카오" # printing value of memory using by call variable print(interset1) print(interset2) print(interset3) print(interset4) # using list structure for binding a lot of value interset = ["삼성전자", "LG전자", "네이버", "카카오"] print(interset) # list is easy handle sequence data woowa = [9130, ..
kospi_top10 = ['삼성전자', 'SK하이닉스', '현대차', '한국전력', '아모레퍼시픽', '제일모직', '삼성전자우', '삼성생명', 'NAVER', '현대모비스'] # before adding print(kospi_top10) # add new item in list kospi_top10.append('SK텔레콤') print(kospi_top10) # change list name kospi_top11 = kospi_top10 print(kospi_top11) # insert new item after of specific item kospi_top11.insert(0, "JOHNMARK_AGC") print(kospi_top11) 실행결과 $ py list_add.py ['삼성전자',..