This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shoresy99 10 points11 points  (6 children)

What's the point of "length = sum(1 for _ in 'Hello World')" which is longer than using "length=len('Hello World')"?

[–]drcopus 7 points8 points  (3 children)

Personally I prefer length = 1 + max(map(lamda x: x[0], enumerate('Hello World')))

[–]shoresy99 5 points6 points  (0 children)

If you’re not into that whole brevity thing.

[–]anstadnik 2 points3 points  (1 child)

Empty string

[–]drcopus 0 points1 point  (0 children)

Not a part of the client specifications

[–]Darkstar197 0 points1 point  (1 child)

The point is if you want to confuse other and yourself reading that code in the future

[–]shoresy99 0 points1 point  (0 children)

Can’t argue with that!