re: Daily Challenge #88 - Recursive Ninjas VIEW POST


Small solution in Python 3.X 😄

def recursive_ninjas(nb: int) -> str:
  return 'chirp.' if nb == 1 else f'chirp-{recursive_ninjas(nb - 1)}'

Nice one! But you forgot an edge case. I can still call it with a negative value and get a recursion error.

# RecursionError: maximum recursion depth exceeded in comparison

I think you should add another if else branch for when the value is less or equal than zero.


Given some context, which is ninjas talking, I doubt that they can talk negativly or that not talking at all is considered as talking

However, without those information, I fully agree ! 😄

I was reading the old ninja scroll all wrong... Thanks sensei 😁

code of conduct - report abuse