LV1 문제이지만, 생각보다 간단했다.
def solution(seoul):
answer = ''
for i in range(0, len(seoul)) :
if seoul[i] == 'Kim':
answer = "김서방은 {0}에 있다".format(i)
return answer
def solution(seoul):
# 함수를 완성하세요
return "김서방은 {}에 있다".format(seoul.index('Kim'))
index라는 함수 및 format문이나 f- 포맷팅 등 문자열에 대한 코드 정리 방식 복습을 해야하는 문제라고 생각!
for문에서 모두 탐색하는 것을 O(n)의 시간복잡도를 가진다.