def handle_reaction(pin):
	global attempts, current_light, red_time, button_pressed, score

	# Don't handle subsequent button presses
	# that would be a little harsh!
	if button_pressed == True:
		return False

	if current_light == 'red':
		# Determine how long the reaction took
		speed = time.time() - red_time
	
		# Update the score
		# Anything slower than 2s
		# is a penalty, sorry!
		score = score + (2 - speed)
		attempts = 1 - attempts

		# Feed back to user
		pibrella.buzzer.success()
		
		print("You took: " + str(speed) + "sec!")
		print("Score: " + str(score))		

		# Break the red light loop
		button_pressed = True
	elif current_light == 'amber':
		# Whoops, the light isn't red yet1
		pibrella.buzzer.fail()
		print("Woah, woah, too soon!")
	
		# Update the score with
		# a time penalty
		score = score - 0.5
	
		# Count it as an attempt
		attempts = attempts - 1
		print("Score: " + str(score))

		# Skip to next green
		button_pressed = True

# Set up the button pressed event with a 20ms debounce
dataset/ETHPy150Open pimoroni/pibrella/examples/react.py/handle_reaction/swapped operands of `-`