'Can Python generate list of all possible part numbers with given criteria?
I am new to Python. As in really new, just venturing if I can use this language in my work.
Can Python generate all the possible part numbers from this list?
Condition:
- Characters are ordered
It can have ERJ3RBD1002V, but not 3RERJBD1002V.
Thank you so much.
Solution 1:[1]
Yes it can, except for the resistance values part (8,9,10,11) since those can be a whole list of values and the link you provided doesn't list them.
Here is a simple code to do it. It will put RRRR into the resistance value part. If you have a list of resistance values, just add them to list R and it will use those to create the combinations:
B = ['1R','2R','3R','6R']
C = ['H','B','K', 'E']
R = ['RRRR']
V = {'1R': 'C', '2R': 'x', '3R': 'V', '6R': 'V'}
for bi in B:
for ci in C:
for ri in R:
print ('ERJ '+ bi + ' ' + ci + ' D ' + ri + ' ' + V[bi])
I put in extra spaces between sections for clarity but you can remove them if you like
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Emrah Diril |
