반응형
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
반응형
'Programming > Python' 카테고리의 다른 글
[Python-Basic] Class Data Type - 1 (0) | 2019.11.05 |
---|---|
[Python-Basic] Tuple Data Type - 1 (0) | 2019.11.05 |
[Python-Basic] List Data Type - 5 (Slicing) (0) | 2019.11.05 |
[Python-Basic] List Data Type - 4 (Remove) (0) | 2019.11.05 |
[Python-Basic] List Data Type - 3 (Index) (0) | 2019.11.05 |