[python, str] join

한라봉·2023년 4월 10일

Python 문법

목록 보기
11/15

https://docs.python.org/3/library/stdtypes.html#str.join

str.join(iterable)

str을 separator로 해서 iterable에 있는 string들을 연결한다.

>>> ''.join(['a','b','c'])
	'abc'
>>> ' '.join(['a', 'b', 'c'])
	'a b c'

프로그래머스 코딩테스트 입문 6일차 문제인 직각삼각형 출력하기 답안으로도 사용할 수 있다.

>>> print('\n'.join(['*'* (i + 1) for i in range(3)]))
	*
    **
    ***
profile
개발자가 되고 싶은 한라봉

0개의 댓글