26
26
["🇮🇳" , "Mumbai" , "India" , 22_089_000 ],
27
27
["🇯🇵" , "Osaka (大阪)" , "Japan" , 18_921_600 ],
28
28
]
29
+ CITY_TITLE = "10 Largest Cities by Population 2025"
30
+ CITY_CAPTION = "Data from https://worldpopulationreview.com/"
29
31
30
32
COUNTRY_HEADERS = [
31
33
'Flag' ,
48
50
["🇷🇺" , "Russia (россия)" , 143_997_000 , 17.1 , 9 , 2_076_396 , 14_258 ],
49
51
["🇪🇹" , "Ethiopia (እትዮጵያ)" , 135_472_000 , 1.1 , 120 , 117_457 , 1_066 ],
50
52
]
53
+ COUNTRY_TITLE = "10 Largest Countries by Population 2025"
54
+ COUNTRY_CAPTION = "Data from https://worldpopulationreview.com/ and Wikipedia"
51
55
52
56
53
57
class TableApp (cmd2 .Cmd ):
@@ -68,9 +72,7 @@ def __init__(self) -> None:
68
72
@cmd2 .with_category (TABLE_CATEGORY )
69
73
def do_cities (self , _ : cmd2 .Statement ) -> None :
70
74
"""Display the cities with the largest population."""
71
- table = Table ()
72
- table .title = "10 Largest Cities by Population 2025"
73
- table .caption = "Data from https://worldpopulationreview.com/"
75
+ table = Table (title = CITY_TITLE , caption = CITY_CAPTION )
74
76
75
77
for header in CITY_HEADERS :
76
78
table .add_column (header )
@@ -85,9 +87,7 @@ def do_cities(self, _: cmd2.Statement) -> None:
85
87
@cmd2 .with_category (TABLE_CATEGORY )
86
88
def do_countries (self , _ : cmd2 .Statement ) -> None :
87
89
"""Display the countries with the largest population."""
88
- table = Table ()
89
- table .title = "10 Largest Countries by Population 2025"
90
- table .caption = "Data from https://worldpopulationreview.com/ and Wikipedia"
90
+ table = Table (title = COUNTRY_TITLE , caption = COUNTRY_CAPTION )
91
91
92
92
for header in COUNTRY_HEADERS :
93
93
justify = "right"
0 commit comments