Ad
Testing

replicate in one line

Code
Diff
  • def replicate(times, num):
        return [] if times <= 0 else [num] + replicate(times-1, num)
    replicate(8,5)
    • def replicate(times, num):
    • if times <= 0: return []
    • return [num] + replicate(times-1, num)
    • return [] if times <= 0 else [num] + replicate(times-1, num)
    • replicate(8,5)