如何找到较高的变量

  • 本文关键字:变量 何找 python
  • 更新时间 :
  • 英文 :


我需要找到更高的变量,但它说:类型错误:">"在"NoneType"one_answers"NoneTType"的实例之间不支持有人能帮我找到total1和total2中较高的数字吗。谢谢

price1 = int(input('Cost of first product($): '))
price2 = int(input('Cost of second product($): '))
mass1 = int(input('Mass of first product(g): '))
mass2 = int(input('Mass of second product(g): '))
total1 = print('The unit price of Product One is', price1/mass1, '$/g.')
total2 = print('The unit price of Product One is', price2/mass2, '$/g.')
if total1 > total2:
print ('Product 1 is of better value.)
price1 = int(input('Cost of first product($): '))
price2 = int(input('Cost of second product($): '))
mass1 = int(input('Mass of first product(g): '))
mass2 = int(input('Mass of second product(g): '))
print('Unit proce of product onr ',price1/mass1,'$/g.')
print('Unit proce of product onr ',price2/mass2 ,'$/g.')
total1 = price1/mass1
total2 = price2/mass2
if total1 > total2:
print ('Product 1 is of better value.')
elif total2>total1:
print ('Product 2 is of better value.')
else:
print ('Product 1 and 2 are equal.')  

"print"return None,这就是为什么你会得到TypeError

最新更新