Skip to content

Instantly share code, notes, and snippets.

@dsomel21
Created December 6, 2016 21:41
Show Gist options
  • Save dsomel21/08d617064c2696dc6e18cb00eb0c0268 to your computer and use it in GitHub Desktop.
Save dsomel21/08d617064c2696dc6e18cb00eb0c0268 to your computer and use it in GitHub Desktop.
# NOTICE THIS ISN'T ALPHABETICAL
dic = {
'Colombia': [48654392, 1090909.09, 'South America'],
'China': [1339190000, 9596960.00, 'Asia']
}
target = open("save.txt", 'w')
# SORTED WILL MAKE IT ALPHABETICAL
for i in sorted(dic):
population = (dic[i][0])
area = dic[i][1]
continent = dic[i][2]
popDensity = population/area
line = i,"|",continent,"|",population,"|",popDensity
target.write(str(line) + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment