Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes: > len() works on dicts and sets, and they're not sequences. Of course dicts and sets are sequences. But there are also sequences on which len doesn't work. You could use: sum(1 for x in seq) Of course iterating through seq may have undesired side effects.