Find the position
Find the position
Search a list and report where something is, counting from 0.
Loop over the positions with range(len(items)), so you have the index i as well as the item items[i]. return leaves the function straight away, which is exactly what you want at the first match. Return -1 only after the loop has checked every item.
위치 찾기
리스트를 검색하여 무언가의 위치를報告하십시오. 인덱스는 0부터 세기 시작합니다.
range(len(items))으로 위치를 순회하여 인덱스 i과 항목 items[i]을 모두 얻으십시오. return은 함수를 즉시 종료시켜, 첫 번째 일치 지점에서 원하는 동작을 합니다. 루프가 모든 항목을 확인한 후에야 -1을 반환하십시오.
Write find_index(items, target) that returns the position of the first target in items, or -1 if it is not there. Do not use .index().
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.