[英]I'm refactoring my code and now I'm getting KeyError: '2'
Can someone help me understand this keyerror that I'm getting?有人可以帮我理解我得到的这个关键错误吗? I've been banging my head against it for 45 minutes, and I've gotten nowhere.
我已经用头撞了它 45 分钟,但我一无所获。 I'm sure it's simple, but I'm not seeing the problem.
我确定这很简单,但我没有看到问题所在。 I would appreciate someone dropping a little knowledge on me.
我会很感激有人对我有所了解。
Die_Generator Die_Generator
while True:
user_input1 = input('Select die to roll: ').upper()
print("check1")
selected_die = sd.die_selector(user_input1)
print("check2")
# Choose your dice quantity
user_input2 = input('Select die quantity to roll: ').upper()
print("check3")
selected_quantity = sq.quantity_selector(user_input2)
print("check4")
# Calculate your roll(s)
calculation = ca.calc(user_input1, user_input2)
Calculation计算
import Data
import random
def calc(inp1: object, inp2: object) -> object:
i = 1
while i <= int(inp2):
print('Rolling' + ' ' + str(inp2) + ' ' +
str(inp1))
while i <= int(inp2):
out1 = (
'Die ' + str(i) + ' = ' +
str(random.randrange(1, int(Data.Die_Available[str(inp2)]))))
i += 1
return out1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.