擅长:python、mysql、java
<p>在您发布的代码中,您将lower()放入并与大写输入进行比较,但是,
lower()和upper()函数返回转换后的字符串,它不会改变当前字符串</p>
<p>我已将您的代码更改为:</p>
<pre><code>def patternSum(myDice):
if allSame(myDice):
patternPoints=input("\nWould you like to score the pattern points for all different values (25 points)? [Y/N]: ")
if patternPoints.lower() == "y":
points = 25
sumDice=input("Would you like to score the sum of the dice (16 points)? [Y/N]: ")
if sumDice.upper() == "Y":
points = 25 + 16
if sumDice == "Y":
points = 16
elif patternPoints.upper() == "n":
sumDice=input("Would you like to score the sum of the dice (16 points)? [Y/N]: ")
points = 16
else:
print("Please try again by entering Y or N.")
else:
points = sum(myDice)
print( "Your score is now:",patternSum([1,1,1,1,1]),".\n" )
return points
score = score + patternSum(myDice)
</code></pre>