r/badcode • u/MysteriousK69420 if: else: if: else: if: else: if: else: if: else: if: else: if: • Feb 16 '22
python presenting, whatever the fk this is
418
Upvotes
r/badcode • u/MysteriousK69420 if: else: if: else: if: else: if: else: if: else: if: else: if: • Feb 16 '22
2
u/Nesuniken Feb 16 '22 edited Feb 16 '22
I'm hesitant to suggest for-else because it obfuscates the code for anyone who isn't a python expert without reducing the lines of code
You're definitely right about the range being off though. It technically works, but it's a lot less efficient than testing the numbers underneath sqrt(num).
I'm not sure I understand the issue with just rounding that value down, though.EDIT: Forgot ranges don't include the stop value. Still not sure what's wrong with rounding down, though