如何修复这个程序中的EOL语法错误

2024-06-16 09:33:54 发布

您现在位置:Python中文网/ 问答频道 /正文

I tried running this program that I made but it kept having the message "SyntaxError, EOL while scanning string literal

随机导入 导入数学

def RoTMG_HP_函数(): 初始值=0 对于范围(19)内的x: 初始+=(随机.randint(-5,5) 返回首字母

''print(RoTMG_HP_Function())'''

def Roll_模拟器(x): x=int(输入(“输入模拟数量。”) 滚动列表=[] 对于范围(x)中的i: RollsList.append(str(RoTMG_HP_函数())

'''#Miscellaneous code, just test case, not relevant
for i in range (-95,96):
    Listcount = 0
    for j in range (200):
        if int(Rollslist[j]) == i:
            Listcount +=1
    if Listcount > 0:
        print('The roll of ' + str(i) + ' appears ' + str(Listcount) + ' times. ')''''
LifepotExpenditure = 0
for i in range (-19,20):
    Listcount = 0
    RollsLower = 0
    for j in range (x):
        if math.floor(int(RollsList[j]) // 5) == i:
            Listcount +=1
        elif math.floor(int(RollsList[j]) // 5) < i:
            RollsLower += 1
    if Listcount > 0:
        print('Differential of ' + str(i) + ': ' + str(Listcount) + '. The probability of this is ' + str(float(100*Listcount / x)) + '%. The probability of a worse roll is ' + str(float(100*RollsLower / x)) + '%.')
    LifepotExpenditure += i*(Listcount)
AverageLifepotExpenditure = float(19.0) - float(LifepotExpenditure / x)
print('\n' + 'On average, you will spend ' + str(AverageLifepotExpenditure) + ' lifepots to max life.')

打印(Roll_模拟器(21))


Tags: oftheinforifrangefloatint