#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목list.pop() 메소드2021-11-12 17:13
작성자

Lecture15_Search에서 sentinel search를 할 때 중간에 아래와 같이 pop 메소드를 사용하셨는데 pop 메소드는 마지막 값을 지우고 그 값을 return하는 걸로 알고 있습니다. 함수 속의 메소드에 있는 return으로는 함수가 종료되지 않는 건가요?

def Sent_linear_search(lst, value):
  lst.append(value)
  i = 0
  while lst[i] != value:
    i += 1

  lst.pop()

  if i == len(lst):
    return -1
  else:
    return i
#pop# method# list# function
댓글
이전[re]init2021-11-18
다음[re]list.pop() 메소드2021-11-13