我正在尝试为我的姐妹 microbit 制作更高或更低的游戏,但我的变量
random_int
&有问题r_number
:
from microbit import *
import random
random_int = random.randint(0, 9)
r_number = 7
while True:
display.scroll(r_number)
if button_a.is_pressed():
display.scroll("HIGHER")
r_number = random_int
display.scroll(random_int)
if r_number =< random_int):
display.scroll('correct')
elif r_number >= random_int):
display.scroll('incorrect')
r_number = random_int
elif button_b.is_pressed():
display.scroll("LOWER")
r_number = random_int
display.scroll(random_int)
if r_number => random_int):
display.scroll('correct')
elif r_number <= random_int):
display.scroll('incorrect')
r_number = random_int