Float' Object Has No Attribute

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

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

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest