# can't repeat function inside while True

hello, i can't get this piece of code working and i have no idea as to why...

def ABC():
while True:
some codes
################################
(Mainloop)
while True

some codes

ABC()

some codes

the above code repeats mainloop indefinitely,
and when it arrives at the ABC() function, it should indefinitely repeat ABC(), until the code breaks when it fulfills the condition that requires it

however, what i am experiencing is, the ABC() only goes through once.
it doesn't repeat, it's as if "while True" inside def ACB() is being ignored...
so, it just goes through ABC and continues on with the rest of the codes in main loop...

can somebody help me please T.T...

## Question information

Language:
English Edit question
Status:
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2016-12-24
2016-12-25
 Alex Lunyov (lunyov-av) said on 2016-12-24: #1

At first check the breaking condition of ABC() infinite cycle. Check using of global and local variables in "Mainloop" and ABC loop.

 david (dovidu) said on 2016-12-25: #2

the strange thing is , even if the breaking condition is not included in the ABC() infinite cycle, it still goes through only once, and continues on back to the main loop...

 RaiMan (raimund-hocke) said on 2016-12-25: #3

this simply does what it should.
So just check your code agains this template:

nMax = 3
nMain = 0

def sub():
nSub = 0
while True:
# prepare break check
nSub += 1
if nSub > nMax: break # check break condition
print "sub:", nSub

while True:
# prepare break check
nMain += 1
if nMain > nMax: break # check break condition
print "main:", nMain
sub()