Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- number_of_barcodes = int(input())
- pattern = r"@[#]+([A-Z][a-zA-Z\d]{4,}[A-Z])@[#]+"
- for _ in range(number_of_barcodes):
- barcode = input()
- if re.match(pattern, barcode):
- digits = re.findall(r"\d", barcode)
- if digits:
- print(f"Product group: {''.join(digits)}")
- else:
- print("Product group: 00")
- else:
- print("Invalid barcode")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement