擅长:python、mysql、java
<p>试试这个:</p>
<pre><code> print("Welcome...")
print("You are are playing a game of dice, this is a two player game, who ever rolls the highest number wins")
name1 = input("What is Player 1's Name?") #Inputs "player 1's" name
print("Hello", name1)
name2 = input("What is Player 2's Name?")
print("Greetings",name2)
from random import randint
Dice = int(input("Please select number of dice you would like to use (atleast 1)"))
Sides = int(input("Please select number of sides on dice you would like to use"))
print("You have selected", Dice," dice and", Sides,"Sides")
Roll1=0
Roll2=0
for i in range(Dice):
Roll1 += randint(1,Sides)
Roll2 += randint(1,Sides)
print ("Player 1's Roll")
print(Roll1)
print ("Player 2's Roll")
print (Roll2)
</code></pre>
<p>更改:首先,代码中不需要第一行。其次,您将<code>int</code>应用于错误的行。<code>randint</code>返回<code>int</code>,但<code>input</code>返回<code>string</code>。第三,在<code>Dice</code>和<code>Sides</code>之间生成一个随机数。我修改为在1和<code>Sides</code>之间生成<code>Dice</code>随机数</p>