将列表元素转换为int时发生ValueError

时间:2018-11-21 17:09:13

标签: list dictionary

无法输入为int,它第一次起作用,我无法再次运行它。它将引发ValueError:int()的无效文字,基数为10:”

nC=int(input("Enter the number of columns: "))
nameoFCol={}
if nC<1:
    print("There must be atleast one column dude!!\nTry again!!")
else:
    for i in range(nC):
        key=input("Please enter the column name: ")
        ListValues= [int(x) for x in input("Please enter the column 
values\n").split(' ')]
        nameoFCol[key] = ListValues
    print (nameoFCol)

0 个答案:

没有答案