Skip to content
Advertisement

One line repeating counter with itertools?

I want to write an infinte generator using itertools that combines a the count and repeat iterators, by repeating each number n times before incrementing. Is there a more concise way to do it than what I came up with?

JavaScript

Advertisement

Answer

Use integer division!

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement