The program here is simply supposed to tell you the shipping charge based off of the weight of the package. I am just wondering if there is any further way to concise it? At the moment, I do not think it can go any further than that. The only place where I'm unsure whether I could improve it, could be Booleans. Possibly use a while
statement?
def main():
weight = eval(input("Please enter the weight of the package: "))
rate = 0
if weight <= 2:
rate += 1.25
elif weight > 2 and weight <= 5:
rate += 2.35
elif weight > 5 and weight <= 10:
rate += 4.05
elif weight > 10:
rate += 5.55
charge = rate * weight
print("The shipping charge is: $%s" % charge)
print(main())
weight = eval(input("Please enter the weight of the package: "))
it's extremely important to not do this. You do not want to evaluate untrusted code, it creates a massive security hole in your code. \$\endgroup\$