fork(1) download
  1. def cleDeControle(chars):
  2. factor = [7, 3, 1]
  3. result = 0
  4.  
  5. for index, char in enumerate(chars.upper()):
  6. if char == '<':
  7. char = 0
  8. elif char >= 'A' and char <= 'Z':
  9. char = ord(char) - 55
  10. else:
  11. char = int(char)
  12.  
  13. result += char * factor[index % 3]
  14.  
  15. return result % 10
  16.  
  17. print cleDeControle('IDFRABRETON<<<<<<<<<<<<<<<<<<<0810381508081006186THOMAS<<<<<<<<6403201M')
Success #stdin #stdout 0.03s 63504KB
stdin
Standard input is empty
stdout
5