Udacity CS101 과정 (Python)을 수강하고 있습니다. 아래의 문제와 해결책은 "2 단원 : 문제 세트 - 마지막 찾기"while 루프는 언제 멈출 지 어떻게 알 수 있습니까?
내 질문 : 아래 코드의 while 루프는 언제 멈출 지 어떻게 알 수 있습니까?
# Define a procedure, find_last, that takes as input
# two strings, a search string and a target string,
# and returns the last position in the search string
# where the target string appears, or -1 if there
# are no occurences.
#
# Example: find_last('aaaa', 'a') returns 3
# Make sure your procedure has a return statement.
def find_last(s,t):
last_pos = -1
while True:
pos = s.find(t, last_pos+1)
if pos == -1:
return last_pos
last_pos = pos
요즘 누가 '프로 시저'라는 단어를 사용합니까? – devnull
70 년대 이래로 학교 밖에서 프로그래밍되지 않은 @devnull 교수님들? : p – keyser
* procedure *의 엄격한 정의가 있지만 함수가 값을 반환하기 때문에 여기서 수행되지 않습니다. – tripleee