| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | 
"""Calculate percentage level of index for regionsinside the Verenigde Nederlanden."""REGIONS = {    'Northern Netherlands': None,    'Eastern Netherlands': None,    'Southern Netherlands': None,    'Western Netherlands': None,    'Amsterdam': None,    'Luxembourg': None,}PRINT_DENSE = Truedef region_in_string(string):    """Look for region in string"""    for region in REGIONS:        if region in string:            return True    return Falsedef calculate_index():    """Calculate index bases on file"""    with open('index.txt', 'r') as file:        line_nr = 0        last_percentage = 11        for line in file:            line_nr += 1            if region_in_string(line):                percentage = 11 - 10 / 998 * (line_nr - 3)                diff_percentage = last_percentage - percentage                last_percentage = percentage                region = line.strip().split('\t')                REGIONS[region[0].strip()] = percentage                if not PRINT_DENSE:                    print('%40s %2s %6.2f %% %6.2f %%' % (                        region[0],                        region[1],                        percentage,                        diff_percentage                    ))        if PRINT_DENSE:            index = 1            length = len(REGIONS)            for region in REGIONS:                if index == length:                    print('%.2f' % REGIONS[region])                else:                    print('%.2f,' % REGIONS[region], end='')                index += 1if __name__ == '__main__':    calculate_index()
 |