Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern_valid = r"@#+([A-Z][A-Za-z0-9]{4,}[A-Z])@#+"
- pattern_digits = r"\d+"
- count = int(input())
- for _ in range(count):
- barcode = input()
- valid = re.search(pattern_valid, barcode)
- if not valid:
- print("Invalid barcode")
- continue
- digits_group = re.findall(pattern_digits, valid.group(1))
- if not digits_group:
- print("Product group: 00")
- else:
- print(f"Product group: {''.join(digits_group)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement