Python Programming Tutorial | Recursive Functions Part 2/2

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Thank you really helped clarify, one additional thing I'd love to see would be how to use recursion for an accumulator.

KitsuneGrl
Автор

This was incredibly helpful. Thank you!

simaphore
Автор

How can I save the result in a new list?
And that all the results in a recursion are saved in that list??

ronjagdfeld
Автор

Can someone explain how he got 'h e l l o' ?

def explode(word):
if len(word) <= 1:
print(word)
return word
else:
print(word[0] + ' ' + word[1:])
return word[0] + ' ' + explode(word[1:])

print(explode('hello'))

this will give you this:
h ello
e llo
l lo
l o
o
h e l l o

How the does the program return 'o' and print 'h e l l o ' when the last thing it prints is 'o' ?

darchcruise
Автор

but your removeDups function only works for adjecent duplicates, how to make it remove all??

BongelaMnguni