NameError: name 'randint' ist nicht definiert

options = [ "Choice 1: 1-9", "Choice 2: 10- 100",  ]
button = buttonbox ( msg = "Choose your range of numbers", title = "Select number range", choices = options)

if button == "Choice 1: 1-9":
 from random import randint
rn1 = randint(30,50)
from random import randint
rn2 = randint(30,50)

options = [ "Close"]
buttonbox ( msg = "%s X %s = ___" % (rn1, rn2), title = "Select number range", choices = options)
if button == "Choice 2: 10- 100":
 from random import randint
rn2 = randint (10,100)
from random import randint
rn2 = randint (10,100)
options = [ "Close"]
buttonbox ( msg = "%s X %s = ___" % (rn1, rn2), title = "Select number range", choices = options)

Dies ist mein code, wenn ich versuche, und führen Sie die zweite Wahl, es sagt NameError: name 'randint' is not defined obwohl der code exakt der gleiche wie die erste option, aber mit unterschiedlichen zahlen.

Irgendwelche Vorschläge?

Schreibe einen Kommentar