[프로그래머스] 서울에서 김서방 찾기

YEAh·2021년 5월 9일
0
post-thumbnail

🔗 문제 링크

https://programmers.co.kr/learn/courses/30/lessons/12919


💻 코드

def solution(seoul):
    idx = seoul.index("Kim")
    answer = "김서방은 " + str(idx) + "에 있다"
    # answer = "김서방은 {}에 있다".format(seoul.index("Kim"))
    return answer

📝 정리

파이썬 format()

문자열 중간에 특정 변수의 값을 넣어 주기 위해 사용

    answer = "김서방은 {}에 있다".format(1)
profile
End up being.

0개의 댓글