'In this application, i used openpyxl to create an application to show statistics about different counteries , so my code does not run at all
In this application, i used openpyxl to create an application to show statistics about different countries. The statistics about each country will be in a file named after this country as show in the following examples, with each row having two values: the name of a state / province, governance and its population. It is possible also to store each country in a sheet inside the same Excel workbook so,my code does not run .
from openpyxl import load_workbook
counteries = ['Egypt', 'USA', 'Canada']
countery = input("Enter the countery: ").title()
while countery not in counteries:
print("Unfound countery || Try another one")
countery = input("Enter the countery: ").title()
countery += str('.xlsx')
book = load_workbook(countery)
global X
sheet = book.active
for i in range(1, 330):
cell2 = sheet['b' + str(i)]
if cell2.value == None:
X = i - 1
break
cells = sheet['A3': 'b' + str(x)]
max = 0
min = 90000
for c1, c2 in cells:
print("{0: 28} {1: 28}".format(c1.value, c2.value))
if c2.value < min:
min = c2.value
min_city = c1.value
if c2.value > max:
max = c2.value
max_city = c1.value
print("The biggest population in " + max_city + " is " + max)
print("The lowest population in " + min_city + " is " + min)
print("The population of the " + sheet['A2'].value + " is " + sheet['b2'])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
