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.
Advertisement
Answer
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:
JavaScript
x
10
10
1
B = ['1R','2R','3R','6R']
2
C = ['H','B','K', 'E']
3
R = ['RRRR']
4
V = {'1R': 'C', '2R': 'x', '3R': 'V', '6R': 'V'}
5
6
for bi in B:
7
for ci in C:
8
for ri in R:
9
print ('ERJ '+ bi + ' ' + ci + ' D ' + ri + ' ' + V[bi])
10
I put in extra spaces between sections for clarity but you can remove them if you like