r/PythonLearning • • Sep 14 '26

🥲Don't know why I wrote this code NSFW

Post image
139 Upvotes

35 comments sorted by

•

u/Sea-Ad7805 Sep 14 '26 edited Sep 14 '26

It's wrong, you don't test for True/False values.

EDIT: I forgot, using any() is more elegant, and faster because it's done when it sees the first True value:

Run this program instead in Memory Graph Web Debugger to see the program state change step by step.

→ More replies (3)

9

u/Mamuschkaa Sep 14 '26 • Bravo

Replace len(...) with sum(...) so that if some of the variables get false, they are not counted.

1

u/ProgramBrave718 Sep 14 '26

Okay thanks for telling me

1

u/pajtonas Sep 14 '26

Best advice both in and out of python 🥲🫡

2

u/DR4C0_R41 Sep 14 '26

Very helpful for therapy lol.

2

u/Lachtheblock Sep 14 '26

Even if all of those were false, you'd still have too many problems.

1

u/ProgramBrave718 Sep 14 '26

Yeah, 😂 But could use sum to make them zero instead of len

18

u/MudFrosty1869 Sep 14 '26 • Bravo

This ain't code, this is a diary entry.

2

u/Naive_Programmer_232 Sep 14 '26

well, it's logical

3

u/SupermarketOk6829 Sep 14 '26

Not so much. It doesn't filter out Booleans before checking length.

2

u/ProgramBrave718 Sep 14 '26

I could use sum for counting true values. But, there are no false values. So, why need to filter Also, it looks messy because there is no false . I know. I wrote gibberish because yk... It's not a good example.. Written in stress

4

u/Naive_Programmer_232 Sep 14 '26

it's logical beyond the code

2

u/SupermarketOk6829 Sep 14 '26

only one thing needed to address the list : Money. Lol

3

u/Naive_Programmer_232 Sep 14 '26

yes exactly haha.

1

u/python_gramps Sep 14 '26

Instead of len(my_life), sum(my_life) will return the number of trues.

1

u/ProgramBrave718 Sep 14 '26

Yeah, i will keep it in my mind

2

u/Traditional_Good_792 Sep 14 '26

Get a heartbreak you will be fixed

2

u/davisousamalbatahan Sep 14 '26

Sjsjsjsjdkdkdjdkdkdk

2

u/jeman_jmbt_mntn Sep 14 '26

Deymmmm brow you have many problems 😂

2

u/[deleted] Sep 14 '26

funniest polish python joke is the fact that bool("dupy") evaluates to True, because you pronounce it the same as "ból dupy"

https://en.wiktionary.org/wiki/b%C3%B3l_dupy

4

u/mixedd Sep 14 '26 • Bravo Regret

Story of my life 😅

2

u/Next-Call8862 Sep 14 '26

del my_life[:len(my_life)]

That should do it.

0

u/code_tutor Sep 17 '26

A huge number of covid babies are struggling from no social interaction. They just default into programming because they spend their entire lives brainrotting at a computer. I hope that you maintain a good social life and are not trying to turn addiction into a career.

1

u/ProgramBrave718 Sep 17 '26

Go and touch grass because you have been advising a lot of covid babies on reddit. Have a good day 😊

0

u/[deleted] Sep 14 '26

[deleted] — view deleted comment