'How do I find out the higher variable
I need to find the higher variable but it says: TypeError: '>' not supported between instances of 'NoneType' and 'NoneType' could anyone help me find the higher number of total1 and total2. thank you
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.)
Solution 1:[1]
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 , that why you are getting TypeError
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | zeeshan12396 |
