Raspberry Pi - gpiozero Library
You want to count how many times a button is pressed using a callback. Which code snippet correctly updates a counter variable?
from gpiozero import Button
count = 0
button = Button(6)
def increment():
global count
count += 1
button.when_pressed = increment
input('Exit')