I currently have this code here:
test = 2.432
test_formatted = "{:.2f}".format(test)
print(test_formatted)
Output:
2.43
Is there a way to insert a variable for the number into the format string? Such as:
test = 2.432
te = 2
test_formatted = "{:." + str(te) + "f}".format(test)
print(test_formatted)
Thanks!
f"{te:.2f}"I'm not sure what your expected result is, can you explain?