python对象不可订阅_python - Python Math - TypeError:'NoneType'对象不可订阅 - 堆栈内存溢出...

该函数返回None。

将结果分配给第14行中的“lista”时

lista = list.sort(lista)

您将其区域设置为无。 那是错误。 没有总是没有数据,也不能下载。 “TypeError:'NoneType'对象不可订阅”

要更正此错误(对列表进行排序),请执行第14行:

lista.sort() # this will sort the list in line

但是还有一些其他错误:在第18行分配时:

list = [v2, v4]

你破坏这个内置类型“列表”,你会收到以下错误:

TypeError: 'list' object is not callable

为了纠正这个,请说:

lista2 = [v2, v4]

在第19行再次出现第14行的相同错误。这样做可以对另一个列表进行排序:

lista2.sort()

在第21行中,您尝试索引内置类型列表。 要纠正这样做:

b = lista2[1] = lista2[0]

有了这个你的代码将运行正常。 最后整个正确的代码:

import math

print("The format you should consider:")

print str("value 1a")+str(" + ")+str("value 2")+str(" = ")+str("value 3a ")+str("value 4")+str("\n")

print("Do not include the letters in the input, it automatically adds them")

v1 = input("Value 1: ")

v2 = input("Value 2: ")

v3 = input("Value 3: ")

v4 = input("Value 4: ")

lista = [v1, v3]

lista.sort()

a = lista[1] - lista[0]

lista2 = [v2, v4]

lista2.sort()

b = lista2[1] = lista2[0]

print str(a)+str("a")+str(" = ")+str(b)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值