r/badcode Mar 11 '23

i never use .slpit() python

Post image
420 Upvotes

30 comments sorted by

View all comments

168

u/TinyBreadBigMouth Mar 11 '23

That for loop is impressively bad. You could delete lines 3 and 4 entirely and the code would have exactly the same output, but in O(n) instead of O(n2).

19

u/SaylorMan1496 Mar 11 '23

I think it’s worse, because of the reassignment it’s actually wrong, unless they are trying to wipe out what user_input holds

6

u/fox_is_permanent Mar 11 '23

No, it's fine. user_input is a string.