문자열끼리 + 연산
a, b = "apple", "banana"
print(a + b)
>> applebanana
join 함수 이용
','.join(['1', '2', '3']) -> '1,2,3'
':'.join(['11', '22', '33']) -> '11:22:33'
''.join(['a','b','c']) -> 'abc'
구분값이 없이 각 문자열을 하나로 합치려면 구분값으로 ''를 이용하면 된다.
a, b, c = "apple", "banana", "candy"
tot_str = "".join([a, b, c])
print(tot_str)
>> applebananacandy
'Python > [개념 및 문법]' 카테고리의 다른 글
[python] 문자열 찾기, 문자열의 특정 위치 찾기_ index, find 함수 (0) | 2023.07.04 |
---|---|
[python] 특정 문자열이 있는지 찾기_slicing, for 문 이용 (0) | 2023.07.04 |
[python] 주어진 숫자들 중 최댓값, 최솟값 구하기 구현 (0) | 2023.07.02 |
[python] 특정 원소의 개수 세기 cnt, count (0) | 2023.06.30 |
[python] 특정 위치의 문자 찾기 index / enumerate / in / not in (0) | 2023.06.30 |