Please pay attention to the formatting.
If your question had the correct formatting, you would have had an answer in a few minutes. Because of the wrong formatting, the question was understandable, and no one tried to answer. I had seen the question, and declined to answer, because I realized it would take me longer to understand the question than to find the correct answer.
Now, after noticing that:
- your double quotes are not double quotes
- that bold format that doesn’t make any sense to be bold (unless, as I thought at first, you wanted to emphasize the “format” word)
- that
dict.format
that doesn’t exist (Python dictionaries don’t have a format
member, so you can’t see that message)
… I tried to reverse engineering your badly formatted question, and figured it out: your list contains a dictionary, and you are trying to format the dictionary, not a number!
>>> Sorted_list = [1, 2, {}]
>>> ["{:.0%}".format(num) for num in Sorted_list]
TypeError: unsupported format string passed to dict.__format__
And now I’m going to go one step further, I will reverse engineer your intention, guessing at the code you have, which you are not showing. I’m guessing that your Sorted_list
contains dictionaries, not values, and you are trying to format the values inside the dictionary:
And now, one more step, going further, I’m guessing that you are trying to show the values on this dictionary in a grid panel. If that is the case, you can completely skip this formatting, and format the numbers when they are added to the grid panel. In the data binding property, instead of typing item['col1']
, you should type "{:.0%}".format(item['col1'])
, which will read and format the value when it is shown in the grid panel.
But I may be overshooting here