Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- counts = input()
- counts = int(counts)
- def is_valid(barcode):
- if re.search('^@#+([A-Z][a-zA-z0-9]+[A-Z])@#+$', barcode) and '_' not in barcode and (len(barcode.replace('@', '').replace('#', '')) >= 6):
- return True
- else:
- return False
- while counts > 0:
- barcode = input()
- if is_valid(barcode):
- product_group = ''.join(re.findall('\d+', barcode))
- if len(product_group) == 0:
- product_group = '00'
- print(f"Product group: {product_group}")
- else:
- print('Invalid barcode')
- counts -= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement