r/PythonLearning • u/DrFrazen • Nov 19 '25
Why isn’t this working
Hello im having a problem using my python code and sorry if its like a dumb question im really new at this
29
u/ianrob1201 Nov 19 '25
Your immediate question has already been answered, but you really need to name your variables better. When you come back to this in two days time are you going to remember what all those letters mean? Certainly for me looking at this, it's not very obvious what it's supposed to be doing.
The only exception to this rule is a "for" loop, where we often use i, x, n or similar. Every other variable should be well named so anyone can understand what it's doing. You might well be thinking "it's okay, I'll name them better once I figure it out" but you don't want to get in that habit as it only makes your life harder.
6
u/tiredITguy42 Nov 19 '25
I just add, that you always name everything in english. English is for programming, what Latin is for medicine. It is a very good habit to use english from the beginning.
12
15
5
4
5
2
u/Individual-Age1163 Nov 19 '25
add suites(0) in the last line of the code then run it again , you are welcome🤗
2
1
1
1
1
Nov 20 '25
It is working! You defined a function. When you run the code, it will define the function. Done!
1
u/TalesGameStudio Nov 20 '25
You got to wait until K is smaller than N. (Which will never happen if the condition isn't fulfilled in the first place, since K is only increasing)
So the only way not being caught in an endless while loop in N>=0. Then it will throw an error, because W is not defined.
1
1
u/DoctorSmith2000 Nov 20 '25
At this point just stop coding and go to study the theory again. A function has to called to be executed
1
1
1
1
u/Usual-Addendum2054 Nov 22 '25
You have not called the function , that's why it is not executing anything
1
u/No_Requirement5979 Jan 27 '26
call this function outside this function definition, in global space with some number as argument
0
4
Nov 19 '25
[removed] — view removed comment
2
u/laptop_battery_low Nov 20 '25
def functionName(variables) is incorrect terminology.
its functionName(parameters). When you actually call the function, the parameters become arguments.
0
-4
47
u/TheBB Nov 19 '25
You've written a function but it isn't being called. Try doing
suites(4)or whatever other number.