I run into the following error when attempting to format string in python,
TypeError: unsupported format string passed to tuple.__format__
def prop_details(address):
if address:
mv = 216164970,
av = 191088,
totalsqft = 663487
return ("${:,.0f}".format(mv), "${:,.0f}".format(av), totalsqft)
Advertisement
Answer
when you write:
mv = 216164970,
then mv becomes a tuple.
Try without the comma…
Also, I find the f-string syntax clearer. You may want to take advantage of it if you are using Python >=3.6:
def prop_details(address):
if address:
mv = 216164970
av = 191088
totalsqft = 663487
else:
mv, av, totalsqft = 0, 0, 0
return f'${mv:,.0f}', f'${av:,.0f}', totalsqft
>>> prop_details(1)
('$216,164,970', '$191,088', 663487)