Project question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Project question

I'm working on a little test code but keep getting operator errors due to my if statement conditions. what's the error I'm making here? total = input("What is your shopping total?") if (total > 1000): discount = total * 0.1 truetotal = total - discount print (truetotal) else: print (total)

24th Oct 2018, 1:36 PM
Fowler Myles
Fowler Myles - avatar
2 Answers
+ 5
input in Python is automatically string format, so you first need to convert it to a real number with int(total) or float(total).
24th Oct 2018, 1:44 PM
HonFu
HonFu - avatar
+ 1
thanks so much Shifu
24th Oct 2018, 1:45 PM
Fowler Myles
Fowler Myles - avatar