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

단간단간·2024년 3월 27일
0

알고리즘 문제

목록 보기
19/106

키워드 : 문자열, 리스트에서 문자열 찾기

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

python 풀이 방법 1)

def solution(seoul):
    for i in range(len(seoul)):
        if seoul[i] == "Kim":
            return f"김서방은 {i}에 있다"

python 풀이 방법 2)

def solution(seoul):
    return f"김서방은 {seoul.index('Kim')}에 있다"
profile
simple is best

0개의 댓글