fork download
  1. # your code goes here
  2. from collections import defaultdict
  3. from itertools import count
  4.  
  5. d = defaultdict(count().__next__)
  6. d[1]
  7. d[2]
  8. d[3]
  9. d[1]
  10. print(d)
Success #stdin #stdout 0.01s 28384KB
stdin
Standard input is empty
stdout
defaultdict(<method-wrapper '__next__' of itertools.count object at 0x2b086e07fc48>, {1: 0, 2: 1, 3: 2})