Я учусь о рекурсии в Python и у меня есть этот код:Python Рекурсия и список
def search(l,key):
"""
locates key in list l. if present, returns location as an index;
else returns False.
PRE: l is a list.
POST: l is unchanged; returns i such that l[i] == key; False otherwise.
"""
if l: # checks if list exists
if l[0] == key: # base case - first index is key
return True
s = search(l[1:], key) # recursion
if s is not False:
return s
return False # returns false if key not found
Может кто-нибудь объяснить мне, что линия
s = search(l[1:], key)
делает именно? и что делает l [1:] в списке?
[здесь] (http://stackoverflow.com/questions/509211/pythons-slice-notation) –
humm, код, похоже, не возвращает 'i, так что l [i] == key' – laike9m