Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*-coding: utf-8 -*-
- import sys, os
- Fehlercode = ["kein Fehler", " String enthält nicht ausschließlich Ziffern", "Nettogewicht ist größer als Bruttogewicht"]
- code = "000024740002506831001250"
- def destroy():
- sys.exit()
- if __name__ == '__main__':
- try:
- #code = input() #eingabe eines 24 stelligen Codes
- anz = 0
- zehner = 1
- netto = 0
- brutto = 0
- while anz < 23: #Überprüfen auf Buchstaben
- if not (code[anz] >= '0' and code [anz] <= '9'):
- print (Fehlercode[1])
- destroy()
- anz += 1
- anz = 13
- while anz > 8: #Netto gewicht
- netto += int(code[anz]) * zehner
- anz -= 1
- zehner *= 10
- anz = 23
- zehner = 1
- while anz > 18: #Brutto gewicht
- brutto += int(code[anz]) * zehner
- anz -= 1
- zehner *= 10
- if netto > brutto:
- print (Fehlercode[2])
- else:
- print (Fehlercode[0])
- except KeyboardInterrupt: # wenn 'CTRL-C' gedrückt, dann Ende
- destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement