我试着运行我制作的这个程序,但它在扫描字符串文字时一直有消息"syntaxerror,eol"
随机进口导入数学
def rotmg_hp_函数():初始=0对于范围(19)中的x:初始值+=(random.randint(-5,5))返回初始值
''print(rotmg_hp_function())''
Def Roll_模拟器(X):x=int(输入("输入模拟次数"))RoSsList=对于范围(x)内的i:rollslist.append(str(rotmg_hp_function())
'''#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('
' + 'On average, you will spend ' + str(AverageLifepotExpenditure) + ' lifepots to max life.')
打印(滚动模拟器(21)
请复制代码并粘贴到这里
查看此答案stackoverflow.com/a/21089462/3562607。很难从图像中分辨出来(您应该将代码粘贴到代码块中或通过其他方式共享代码块)。扫描代码并确保所有引用都正确。
也许你可以使用pastebin.com,但从你的图片来看,它应该已经被接受了。
这条线
print('The roll of ' + str(i) + ' appears ' + str(Listcount) + ' times. ')''''
结尾还有一个逗号,只需删除它
哦,非常感谢
还有一件事与topic@j.martin无关,在我看来您正在开始一些Python开发。我建议使用其他文本编辑器,如Sublime Text、Atom或Notepad++(稍后谷歌搜索,它们非常有用!)