#!/usr/bin/env python3

iban = 'AT483200000012345864'

iban_lengths = {
    'AT': 20,  # Austria
    'DE': 22,  # Germany
    'CH': 21,  # Switzerland
}

iban = iban.replace(' ', '').upper()

country_code = iban[:2]
if country_code not in iban_lengths:
    print('Country code not found')
    exit()
elif len(iban) != iban_lengths[country_code]:
    print('IBAN length is incorrect')
    exit

iban = iban[4:] + iban[:4]
digit_string = ''

for c in iban:
    if c.isdigit():
        digit_string += c
    else:
        digit_string += str(ord(c) - 55)

if int(digit_string) % 97 == 1:
    print('IBAN is valid')
else:
    print('IBAN is invalid')

