0

I have some intro to python homework I can't seem to get right.

The question is : "Write a program to determine how much to tip the server in a restaurant. The tip should be 15% of the check, with a minimum of $2." And the hint suggested to use "if" statement.

This is what I've got so far but I get an error '>' not supported between instances of 'str' and 'float'


Bill = input("Enter bill amount")

if Bill > 13.4: print(Bill*0.15)

else: print(2)



drc91
  • 5
  • 2

1 Answers1

0

input() returns a string. Therefore Bill is a string, and you cannot compare strings to numbers.

You can convert the input value to a floating-point value using float(), like this:

Bill = float(input("Enter bill amount"))
John Gordon
  • 29,573
  • 7
  • 33
  • 58
  • Could you help me create a program for my homework by any chance? I've been trying to come up with something for almost 2 hours now lol – drc91 Nov 12 '22 at 06:05