My solution for this is to put x = 0
outside def main():
part.
If you do this, the incrementation should be good for all code.
x = 0
def main():
global x
[rest of code]
Otherwise you set x = 0 every time inside main()
loop.
CLICK HERE to find out more related problems solutions.