Tips : Join

Austin Jiuk Kim·2022년 3월 24일
0

Python

목록 보기
8/14
# join() cannot combine any other data type except string.
# Because Python reports TypeError when you try to concatenate int and string.
aaa = [1,2,3]
''.join(aaa)
'123'
# join() only can combine string.
aaa = ['1','2','3']
''.join(aaa)
1 + '1'
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/var/folders/y1/pfjkj5cd0wz3vhn094nv_yl80000gn/T/ipykernel_18846/2877782753.py in <module>
----> 1 1 + '1'

TypeError: unsupported operand type(s) for +: 'int' and 'str'
profile
그냥 돼지

0개의 댓글