I just started to learn python. I am getting the following error.

a=15/737 print("String formating with value{r.1.4f}".format(r=a)) 

AttributeError Traceback (most recent call last) in ---- > 1 print ( "string formating with value {r.1.4f}" . format ( r = a ) )

AttributeError : 'float' object has no attribute '1

Can anyone tell me what is worng here?

1

1 Answer

It's a just syntax error:

Put a colon (:) behind r instead of a point(.) and it will work.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy