0
I made a gst calculator and i need help on how can i make my code the way that it don't have to be dependent on the hard coding
#GST Calculator ammount = int(input("ammount: ")) def cal(a): user = int(input("Tax: ")) if user == 18: print(a * 1.18) elif user == 12: print(a * 1.12) else: print("Choose") cal(ammount)
1 Antwort
+ 8
Use a variable which is modified by their input. something like this, I was thinking:
print(a * float("1.%s" % user))
Which will place the user number as the decimal for 1; which seems to be what you want to do.
That way you can avoid infinite if statements for every possible number.