Why is X staying = 1?

67 views Asked by At
while 1:

    x=+1
    pic = pyautogui.screenshot()
    pic.save(str(x)+".png", "PNG")
    print(x)
    time.sleep(5)

X won't increase every time the loop, loops

I want the screenshot to save under a different name every time it screenshots, so I put x=+1 to constantly give a new name for the screen shot to save under but it only stays at one.

1

There are 1 answers

2
AudioBubble On

You should write x += 1 which means x = x + 1.

Here you just value the x to +1 (x = +1)

A little advice: is better to write mathematical syntax with space to don't get problems like this.