Advertisement
Wastebinonpastebin

barcode_scan_new

Sep 29th, 2020 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. # version 2 of https://pastebin.com/C4hu4ys1
  2.  
  3. bc = input("Geben Sie einen Barcode ein: ") #bc = Barcode
  4. def main():
  5.     a =stringcheck()
  6.     b = weightcheck()
  7.     c = a+b
  8.     print(switch(c))
  9.  
  10. def stringcheck():
  11.  
  12.     if bc.isdecimal(): #tests if "bc" only has digits
  13.         return "2"
  14.     else:
  15.         return "1"
  16.  
  17. def weightcheck():
  18.  
  19.     if int(bc[8:13]) > int(bc[18:23]):
  20.         return "2"
  21.     else:
  22.         return "1"
  23.    
  24. def switch(z):
  25.    
  26.     switcher = {
  27.         22 : "Fehlercode 0",
  28.         12 : "Fehlercode 1",
  29.         21 : "Fehlercode 2",
  30.         11 : "Fehlercode 1 und 2"
  31.     }
  32.     return switcher.get(z)
  33.  
  34. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement