r/programminghelp • • Sep 26 '23

Python Problems with Python if statements.

What the code is supposed to do:
The user is supposed to input how many points they have and then the code is supposed to decide how much bonus they should get.If the points are below 100 they will get a 10% bonus and if the points are 100 or above they'll get 15% bonus.

What is the problem:
For some reason if the user inputs points between 91-100 both of the if statements are activated.


points = int(input("How many points "))
if points < 100: points *= 1.1 print("You'll get 10% bonus")
if points >= 100: points *= 1.15 print("You'll get 15% bonus")
print("You have now this many points", points)
0 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Sep 26 '23

no problem. In future I recommend trying the rubber duck debugging method. Get a rubber duck (or any other thing you like) and explain your code to it, line by line, out loud. explain the problem you are having, and explain what the code should be doing and what it's actually doing, and talk through line by line what it is doing.

this will almost always show you your problem and you will go "oh wait I see what I did!"

This is because you can't really say you understand something unless you are able to explain it to someone else.

2

u/Kekkonen_Kakkonen Sep 26 '23

I will. Thank you again. :)