Python Data Analysis Basics 8

https://app.dataquest.io/m/331/python-data-analysis-basics/8/formatting-numbers-inside-strings

Your Code: ```pop_millions = [
[“China”, 1379.302771],
[“India”, 1281.935991],
[“USA”, 326.625791],
[“Indonesia”, 260.580739],
[“Brazil”, 207.353391],
]

template1 = “The population of {} is {:,.2f) million”

for country in pop_millions:
name = country[0]
pop = country[1]
output1 = template1.format(name, pop)
print(output1) ```

What I expected to happen: I expected this code to work since I have the the correct template and output criteria.

What actually happened: But it giving this error
ValueErrorTraceback (most recent call last)
in ()
12 name = country[0]
13 pop = country[1]
—> 14 output1 = template1.format(name, pop)
15 print(output1)

ValueError: unmatched ‘{’ in format spec

Other details:

Hi @dish.met
I think you used ) in place of } in this code

1 Like