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)

7th Jun 2018, 7:57 AM
Bishnu Chourasiya
Bishnu Chourasiya - avatar
1 Answer
+ 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.
7th Jun 2018, 8:31 AM
Ahri Fox
Ahri Fox - avatar