+ 1
Stuck here help
Two friends want to play blackgammon,but lost dice.create a program to replace them.it should roll the dice and output the result of each die Import random random.seed(int(input))) dice1 = random.randint(range(1,6)) dice2 = random.randit(range(1,6)) print(dice1) print(dice2)
2 Respuestas
+ 5
1. You usually don't need to provide a seed for random. It will use the current system time by default. You can also just pass the string as the seed, it will be converted to an int in the seed method, but is also ok to pass as an integer if desired, and will be used directly.
2. You're missing the parentheses for the input() function call.
3. The randint() method takes 2 integer arguments, a start and and end, not a range object.
import random
# random.seed(input()) # this line isn't really needed
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
print(die1)
print(die2)
+ 5
* it is "import", not "Import"
* check the input: you accidentally deleted a (
* read the documentation of randint: it takes arguments like "random.randint(1,6)", not with range()