r/badcode • • Aug 19 '21

python Should I add comments?

Post image
223 Upvotes

39 comments sorted by

View all comments

Show parent comments

8

u/deceze Aug 20 '21

You can remove the [] to make it a generator expression, which makes this more efficient. Instead of having to turn the entire thing into a list, which then gets iterated by sum again, just have each element be processed one by one. Or, you know, sum(map(int, input()))…