For unitversity, we have to program a code, which validates the IBAN of Germany, Suisse and France. The German IBAN DE08700901001234567890 contains the two letters 'DE', the test number 08, the bank number 70090100 and the account number 1234567890. For letters you have to add +9 to his number (A = 10, B = 11,...Z = 35).
For validating an IBAN, the first four numbers have to be shifted to the end and the letters DE should be repleaced with 1314. The validation number 700901001234567890131408 Modul0 97 has to be 1.
We are absolute beginners. The topic of our lecture today was 'while- and for-loops', so the code needs to be easy. I assume, it has something to do with lists, because you add numbers, but we hadn't yet talked about lists in the lecture.
My attempt:
# add 9 to the letter
D = 13
E = 14
F = 15
R = 28
C = 12
H = 17
list = ibannummer = input ('Enter your IBAN number')
if 'DE' in ibannummer :
banknumber = ibannummer[5,6,7,8,9,10,11] #banknumber 70090100
accountumber = ibannummer[12:] #accountnummer 1234567890
valiationnumber = bankleitzahl + kontonummer.append(ibannummer[0,1,2,3])
if valiationnumber % 97 == 1 :
print ('validierte IBAN')
This is just a temporary working theory based on what I understand:
this code however (if you give it a quick run) does not match up with your validation code you gave. If you wanted DE to be considered a number:
I don't see why you had to make all the letters = to a number (i.e D=13) since you check if it starts with DE, which you know is going to be 1314 no matter what.