I am trying to write a Python
code where the user gives a number and the number of decimals it wants to be rounded to. Then the program returns the first number in scientific notation.
My code:
def csign(a,b):
#a=number,b=decimals
a=float(a)
b=float(b)
return "{:.b e}".format(a)
The desired functionality should work like:
input: csign(123456,3)
output: 1.23 e5
But I get an error saying
Format specifier missing precision.
Is there any way I could make the program recognize b
as a precision?