Country list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Country list

I want to practice by making some country list with capital city, region, currency, etc as it attributes for each country. Will it better use inheritance classes for each country or just can store all in the main class Country like below example? class Country: def __init__(self, name, capital, region): self.name = name self.capital = capital self.region = region NZ = Country ("New Zealand", "Wellington", "Oceania")

8th Dec 2016, 7:44 AM
NunNo DeCabunic
NunNo DeCabunic - avatar
1 Answer
+ 2
Since you probably want to have each of the countries as single, differentiated objects but with the same type of data and methods inside, it's the best to use one class for that.
10th Dec 2016, 6:06 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar