DNI checker

Design a function @busca_dni(lista)@ that, given a list listalista of DNI, checks whether all values are valid (that is, their letters correspond to their numerations and they have the required length). The function must return the first invalid DNI found, or str ok if all are valid. You must use function @check_letter(num, letra)@, which given an int numnum and a str letraletra, returns TrueTrue if the letter corresponds with the number or FalseFalse otherwise.

def check_letter(num, letra):
    return letra == 'TRWAGMYFPDXBNJZSQVHLCKE'[num%23]

Sample session

Problem information

Author: InfBesos

Generation: 2026-01-25T17:37:42.540Z

© Jutge.org, 2006–2026.
https://jutge.org