我从下面的原始代码中进一步编辑了这段代码
ALPHA = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def repr2dec(num, base):
total = 0
for ix, digit in enumerate(reversed(num)):
total += ALPHA.index(digit) * base ** ix
return total
print(repr2dec("23", 21) == 45)
print(repr2dec("11", 72) == 73)
print(repr2dec("43", 13) == 55)
print(repr2dec("AD", 15) == 163)
我当前的错误是:
Traceback (most recent call last):
File "nt-test-6269e744", line 3, in <module>
assert(convert.repToDecimal("23", 21) == 45)
AttributeError: module 'convert' has no attribute 'repToDecimal'
我相信我正朝着正确的方向前进,但我无法找到下一步的方向
目前没有回答
相关问题 更多 >
编程相关推荐