# Hungry Hungry Hippo # input 14 and 15 from machine import Pin from time import sleep_ms PlayerA = Pin(15, Pin.IN, Pin.PULL_UP) PlayerB = Pin(14, Pin.IN, Pin.PULL_UP) A = 1 B = 1 Na = 0 Nb = 0 time = 0 flag = 0 print('Press and release buttons to count') while(time < 10): zA = A A = PlayerA.value() zB = B B = PlayerB.value() if( (A==1) & (zA==0) ): Na += 1 flag = 1 if( (B==1) & (zB==0) ): Nb += 1 flag = 1 if(flag == 1): print(Na, Nb) flag = 0 sleep_ms(10) time += 0.01 print('Game Over') if(Na > Nb): print('Player A Wins') elif(Nb > Na): print('Player B Wins') else: print('Tie')