擅长:python、mysql、java
<p>只需在列表中添加x个元素x次:</p>
<pre><code>import random
probabilities = []
player1="John"
print("Calculating", player1 + "'s luck!")
player1num = random.randint(0,100)
newnum = player1num / 2
newnumadded = newnum + 10
if newnumadded > 50:
bonusnum = newnumadded + 25
print(player1 + " Your number is:", str(player1num) + "! You have a percentage to win of: ", str(bonusnum) + "%!")
probabilities.extend([player1 for x in range(0,int(bonusnum))])
else:
print(player1 + " Your number is:", str(player1num) + "! You have a percentage to win of: ", str(newnumadded) + "%!")
probabilities.extend([player1 for x in range(0,int(newnumadded))])
print(probabilities)
</code></pre>