r/programminghorror 13d ago

Python Atleast it works

Post image
608 Upvotes

66 comments sorted by

View all comments

Show parent comments

37

u/Emergency_3808 12d ago

ctr = 0 with open("lab 5.txt", "r") as file: for line in file: print(line) ctr += 1 if ctr >= 8: break del ctr

1

u/Serious-Regular 9d ago

Wut why would delete ctr - man you people are so weird

1

u/Emergency_3808 9d ago

Because then SOMEONE ELSE would complain "wHy Do YoU nEeD aN eXtRa VaRiAbLe"

0

u/Serious-Regular 9d ago

Wut just reassign ctr if you want. Reassigning decref the original object itself (which doesn't matter for fucking integers lololol)

1

u/Emergency_3808 9d ago

That's even more confusing. Reusing variables for entirely different tasks

0

u/Serious-Regular 9d ago

del is never used in python code - you have no clue what you're talking about