Advertisement
Osiris1002

Fancy Barcodes

Mar 29th, 2024
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import re
  2.  
  3. number_of_barcodes = int(input())
  4. pattern = r"@[#]+([A-Z][a-zA-Z\d]{4,}[A-Z])@[#]+"
  5.  
  6. for _ in range(number_of_barcodes):
  7.     barcode = input()
  8.     if re.match(pattern, barcode):
  9.         digits = re.findall(r"\d", barcode)
  10.         if digits:
  11.             print(f"Product group: {''.join(digits)}")
  12.         else:
  13.             print("Product group: 00")
  14.     else:
  15.         print("Invalid barcode")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement