Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A company uses codes to represent its products, for example ABC 2 4 7 5 A 5 R - 1 4 . Valid codes must
A company uses codes to represent its products, for example ABCAR Valid codes must have:
At least characters some codes have more than characters
Positions through must be digits and represents the country in which the product will be sold
The character in the th position must be a capital letter and represents the security level of the product.
Write a Python program that will read product codes from a text file Codestxt attached below Determine if each conforms to the rules listed above:
If it does conform, print a heading: Valid Codes are: and list the codes that are valid. If it does not conform, print a heading: Invalid Codes are: and list the
codes that area invalid. Be sure to test all possible combinations.
Further, if the code is valid, due to new government security laws, products with a security level of restricted are no longer to be sold in countries with a
country code of or higher. Output a heading: Invalid Restricted Codes are: and list the codes that are invalid in case you encounter any products that
violate these new laws. XYZR
RSTAA
UVWaRR
PQRF
STIJA
FORTR
BIDUR
AGAPB
JBTEX
KAMXR
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