Use generator instead of list in code examples (GH-11203)

There is no need to create a list for `sum`
Also, becomes consistent with the first example in Doc/library/os.rst
1 file changed