When using
Then it will be like this with f-string(3,6).
Using pprint will show dictionary in column way.
But lose order.
print
in code,you iterate over dictionary.Then it will be like this with f-string(3,6).
1 2 3 4 5 6 7 |
months = [ 'January' , 'Febuary' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' ] rain = [ 40 , 45 , 30 , 20 , 15 , 12 , 13 , 10 , 17 , 19 , 20 , 35 ] record = dict ( zip (months, rain)) for key,value in record.items(): print ( f '{key} rain --> {value}' ) |
Output:January rain --> 40
Febuary rain --> 45
March rain --> 30
April rain --> 20
May rain --> 15
June rain --> 12
July rain --> 13
August rain --> 10
September rain --> 17
October rain --> 19
November rain --> 20
December rain --> 35
When using REPL(>>>) like ptpython,IPython they can display the dictionary in an other way. Using pprint will show dictionary in column way.
But lose order.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
>>> from pprint import pprint >>> pprint(record) { 'April' : 20 , 'August' : 10 , 'December' : 35 , 'Febuary' : 45 , 'January' : 40 , 'July' : 13 , 'June' : 12 , 'March' : 30 , 'May' : 15 , 'November' : 20 , 'October' : 19 , 'September' : 17 } |