Skip to content
Martin Zelený edited this page Apr 6, 2023 · 1 revision

Náměty

Rekurze

Zjištění délky seznamu bez použití funkce len()

def recursive_len(lst):
    if lst == []:  # nebo if not lst:
        return 0
    return 1 + recursive_len(lst[1:])


recursive_len([2, 4, 5, 4, 3, 4, 3])
Clone this wiki locally