Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- count_of_barcodes = int(input())
- for barcode in range(count_of_barcodes):
- new_barcode = input()
- pattern = r'(\@\#+)([A-Z][A-Za-z0-9]{4,}[A-Z]+)(\1)'
- is_valid = re.findall(pattern, new_barcode)
- if is_valid:
- product_group = ''
- group = re.findall(r'[0-9]+', is_valid[0][1])
- if group:
- product_group = ''.join(group)
- else:
- product_group = '00'
- print(f'Product group: {product_group}')
- else:
- print('Invalid barcode')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement