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])@#+"
- n = int(input())
- for _ in range(n):
- barcode = input()
- match = re.search(pattern_valid, barcode)
- if not match:
- print("Invalid barcode")
- else:
- group = "".join([n for n in match.group(1) if n.isdigit()])
- if not group:
- group = "00"
- print(f"Product group: {group}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement