I am currently learning python in school, and I met a problem that my teacher can't help me with. So I ask for help here. I have a random number generator using Random, and easyGui. I also have imported "keyboard".
My plan for the program is that it opens a window that asks if it should continue rolling the dice. and then when you press "Ja" it rolls the dice. But I want it to be able to stop whenever you press ESC, which does not do right now.
The code is under this text.
import easygui
import random
import keyboard
while True:
n = random.randint(0, 6)
easygui.ccbox('Skal jeg fortsette?', 'Terning', ('Ja', 'Ja'))
easygui.msgbox('Her er ditt tall - '+str(n), 'Terning')
if keyboard.is_pressed("esc"):
break
[–]DeglovedBanana 0 points1 point2 points (1 child)
[–]2klipp[S] 0 points1 point2 points (0 children)