Question
#Imagine you're writing the software for an inventory system for #a store. Part of the software needs to check to see if inputted #product codes
#Imagine you're writing the software for an inventory system for #a store. Part of the software needs to check to see if inputted #product codes are valid. # #A product code is valid if all of the following conditions are #true: # # - The length of the product code is a multiple of 4. It could # be 4, 8, 12, 16, 20, etc. characters long. # - Every character in the product code is either an uppercase # character or a numeral. No lowercase letters or punctuation # marks are permitted. # - The character sequence "A1" appears somewhere in the # product code. # #Write a function called valid_product_code. valid_product_code #should have one parameter, a string. It should return True if #the string is a valid product code, and False if it is not.
False False 21 #Add your code here! 22 def valid_product_code (string): 23 % 4-0: 24 25 26 27 28 29 30 31 32 if len string) for cin list(string): if c "Al": for c in list (string) if c - c.lower): elif c(or"." or" or":") else: return False return False return True else: return False 34 35 36 37 38 39 40 41 #Below are some lines of code that will else: return False test your function. 43 Yunc tion chat ditferent tnputhe variable() to test your 43 #function with different inputs. 44# 45 #If your function works correctly, this will originally 46 #print: True, True, False, False, False 47 print (valid product code( "A12844BP 48 print(valid_product_code("BFDSAUSA98932RWEFOEWA9FEAA1DSFSF")) 49 print (valid product code("A1BBDS") 50 print (valid_product code(BDD5664S") 51 print (valid_product_code "66aBSaA1fdsv"))Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started