λ¬Έμμ΄μ κ²°ν©νλ join ν¨μ
join()
ν¨μλ μ¬λ¬ λ¬Έμμ΄μ νλλ‘ κ²°ν©ν λ μ¬μ©ν©λλ€.
νΉμ ꡬλΆμ(Delimiter)λ₯Ό μ¬μ©νμ¬ λ¬Έμμ΄, 리μ€νΈ, νν λ± λ°λ³΅ κ°λ₯ν κ°μ²΄μ μμλ€μ μ°κ²°ν©λλ€.
'ꡬλΆμ'.join(λ°λ³΅κ°λ₯νκ°μ²΄)
join() ν¨μ μ¬μ© μμ
join()
ν¨μλ κ²°ν©ν λ¬Έμμ΄λ€μ ν¬ν¨ν λ°λ³΅ κ°λ₯ν κ°μ²΄λ₯Ό 맀κ°λ³μ(ν¨μλ₯Ό μ€ννκΈ° μν΄ νμν μ
λ ₯κ°)λ‘ λ°μ΅λλ€.
μ΄ ν¨μλ λ¬Έμμ΄μ κ° μμ μ¬μ΄μ μ§μ λ ꡬλΆμλ₯Ό μ½μ ν΄ νλμ λ¬Έμμ΄λ‘ κ²°ν©ν©λλ€.
words = ['μ¦κ±°μ΄', 'νμ΄μ¬', 'νλ‘κ·Έλλ°'] sentence = ' '.join(words) print("sentence:", sentence) # "μ¦κ±°μ΄ νμ΄μ¬ νλ‘κ·Έλλ°"
join()
ν¨μλ μ¬λ¬ κ°μ λ¬Έμμ΄μ νλλ‘ κ²°ν©νκ±°λ, 리μ€νΈ λλ ννμ λ¬Έμμ΄λ‘ λ³νν λ μ¬μ©ν©λλ€.
words = ['apple', 'banana', 'cherry', 'date', 'fig'] word_joined = ', '.join(words) print("word_joined:", word_joined)
λ¬Έμμ΄ κ²°ν©νκΈ°
μ£Όμ΄μ§ 리μ€νΈμ λ¬Έμμ΄λ€μ ' - ' ꡬλΆμλ‘ κ²°ν©νμ¬ μΆλ ₯νμΈμ. μμ μΆλ ₯κ°μ Hello - World - Python
μ
λλ€.
words = ['Hello', 'World', 'Python']
result = ' - '.join(
)
print(result)
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Execution Result