Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

invalid literal for int() with base 10?

+1 vote
asked Oct 2, 2019 by maxr00m (150 points)
No errors when entering rounded figures for (rate), but when running the below with rate of 35.25, the error message come up (invalid literal for int() with base 10)

==================================

rate = input("Please Enter the Desired Rate ")
if int(rate) > 50:
    print("The Rate is High")
elif int(rate) < 50:
    print("The Rate is Low")
else:
    print("Exactly 50")

=================================

4 Answers

0 votes
answered Oct 3, 2019 by anonymous
use double . always use double for currency .
+1 vote
answered Oct 5, 2019 by anonymous
This error because python is expecting an integer value ie. in simple number without any decimal,

the solution is that you could use float(input()) instead of int(input().
0 votes
answered Oct 9, 2019 by anonymous
Expecting an int.

Either typecast or use a float, double, real
0 votes
answered Nov 7, 2019 by dheeraj (1,090 points)
rate = float(input("Please Enter the Desired Rate "))
if (rate) > 50:
    print("The Rate is High")
elif (rate) < 50:
    print("The Rate is Low")
else:
    print("Exactly 50")
    

output

Please Enter the Desired Rate 50.36
The Rate is High

the mistake u did is yoar taking a float number not a simple number

for both it will work
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...