小编Cri*_*bel的帖子

TypeError:'int'对象不可订阅

我正在尝试创建一个简单的程序,根据命理学告诉你你的幸运数字.我一直收到这个错误:

File "number.py", line 12, in <module>
    sumln = (int(sumall[0])+int(sumall[1]))
TypeError: 'int' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

我的脚本是:

birthday = raw_input("When is your birthday(mm/dd/yyyy)? ")
summ = (int(birthday[0])+int(birthday[1]))
sumd = (int(birthday[3])+int(birthday[4]))
sumy= (int(birthday[6])+int(birthday[7])+int(birthday[8])+int(birthday[9]))
sumall = summ + sumd + sumy
print "The sum of your numbers is", sumall
sumln = (int(sumall[0])+int(sumall[1]))
print "Your lucky number is", sumln`   
Run Code Online (Sandbox Code Playgroud)

python python-2.7

27
推荐指数
3
解决办法
15万
查看次数

标签 统计

python ×1

python-2.7 ×1