zone_counter=1
max_free_spaces=1
zone_with_max_free=0
space_counter=0
occupied_count=0
free_spaces=0
numberOfZones=int(input('Enter the number of zones: '))
spacesPerZone=int(input('Enter the amount of spaces per zone: '))
totalSpaces=0
while zone_counter <= numberOfZones:
    space_counter=0 #to reset space_counter so that it will go back through loop
    free_spaces = 0
    while space_counter < spacesPerZone:
        try:
            occupancyStatus = int(input(f" what is the current occupancy status of space {space_counter +1} in zone {zone_counter}  (1= occupied 0 = available): "))
            if occupancyStatus != 0 and occupancyStatus != 1:
                raise Exception("Invalid Statis, please try again") #allows the user to reattempt to input the correct data if they input a string type
        except:
            print("Invalid Statis, please try again")  #except so that the input can be reattempted
            continue #to break from loop
        if occupancyStatus==1:
            print(f"space {space_counter+1} in zone {zone_counter}  is occupied")
            print()
            occupied_count+=1
            space_counter+=1
        elif occupancyStatus==0: #amended to increment space_counter and free_spaces which was not in the original code
            print(f"space {space_counter+1} in zone {zone_counter}  is available")
            print()
            space_counter+=1
            free_spaces+=1#added to free spaces to get accurately calculate which zone has the most free space
    if free_spaces>max_free_spaces:
        max_free_spaces=free_spaces
        zone_with_max_free=zone_counter
    zone_counter+=1
totalSpaces=numberOfZones * spacesPerZone
free_spaces=totalSpaces-occupied_count
occupancy_percent=(occupied_count/totalSpaces)*100
print(f"The occupied count is: {occupied_count}")
print(f"The current occupancy percentage is: {occupancy_percent:.2f}%")
print(f"The maximum number of spaces available is: {free_spaces}")
print(f"The Zone with the most number of spaces is: {zone_with_max_free}")
if occupancy_percent>80:
    print("Warning: Occupancy of car park is over 80%") #moved out of loop to stop from repeating everytime user inputs 1 or 0