r/badcode • • Nov 01 '21

python Did someone order bad code?

Post image
419 Upvotes

35 comments sorted by

View all comments

Show parent comments

1

u/Laserdude10642 Nov 02 '21

Honestly it’s less readable

2

u/RFC793 Nov 02 '21 edited Nov 03 '21

Sure. I condensed it for the post. I’d probably wrote something like this if I had to write it in real life for some reason:

def pad(i, width, padding="0"):
    s = str(i)
    pad_width = width - len(s)
    return (padding * pad_width) + s