0
Why does this not work? (Python)
#Gets price price = input() tax_rate = 6 #Caculates tax and prints total = ((price / tax_rate) + price) print(total)
3 Respuestas
+ 2
input() always returns a string
+ 1
# The int() function converts a number or a string to its equivalent integer
price = int(input())
+ 1
SwiftSand as others mentioned, price has to get converted from string to a number by using float() (or maybe int(), depending on task requirements). I would add that the code uses tax_rate as a fraction. Is it correct? In my experience tax rate is usually a percentage.