In my program, the user will enter more than one code in the "AB123" format. Based on the entered codes, I have to filter out those that start with the letters "AB" and end with the numbers "00". I have to print and count their number separately from the bulk of all codes, how can this be done?
My current code is:
def main():
code = input("Please enter all codes of your products in format 'AB123':")
print("Your codes are:", code)
pCodes = None
if len(code) == 5 and code.startswith('AB') and code.endswith('00'):
pCodes = code.startswith('AB') and code.endswith('00')
print("Ok, here are your prioritized codes", pCodes)
else:
print("There are no codes with 'AB' letters and '00' digits at the end!")
main()
I tried to integrate a new variable pCodes to assign all codes with letters "AB" and digits "00" but it's not working as planned...