文字无效

时间:2015-02-07 23:31:27

标签: python list dictionary

我刚刚开始编程4-5周前,我遇到了一些问题。我正在尝试创建一个列表高分计划。当我试图在列表中添加高分时,我得到错误"对于带有基数10&#34的int()无效的文字;我会发布我的代码供你查看。所有和任何帮助都很棒。谢谢!

scores = [("Roger", 1400), ("Justin", 2320), ("Beth", 3456)]

print("Hello! Welcome to the high scores!:")

print("\nHere are the current high score leaders!")
print(scores)

print("\n0 - Sort high scores")
print("1 - Add high score")
print("2 - Reverse the order")
print("3 - Remove a score")

print("Please enter your selection")

option = int(input())

if option == 0:
    scores.sort()
    print("These are the scores sorted alphabetically")
    print(scores)


if option == 1:
    print("Please enter your name and score; For example: Joe, 22")
    name, score =( int(input()), int(input()) )
    entry = (name, score)
    scores.append(entry)
    print(scores)

1 个答案:

答案 0 :(得分:0)

name, score =( int(input()), int(input()) )

在这里,您获得2个输入,并尝试将它们转换为整数。但是,名称不是整数。所以,它应该是

name,score = (raw_input(),int(input())
相关问题