Here I am trying to solve sequence problem. I am doing 1:1 model mix sequence from the input. Example:
[sw,cr,dw,sw]
Here I have attached my code. I have a bug. I can't find any.
sw = ['1','4','5','8']
dw = ['3','7']
cr = ['2','6']
#sample output = ['sw 1','dw 1','c 1']
max_item = [len(sw),len(dw),len(cr)]
a=0
b=0
c=0
flag_sw = True
flag_dw = True
flag_cr = True
for i in range(max(max_item)):
if (flag_sw)|(flag_dw)|(flag_cr)== False:
break
# Single Weld
try:
print(i,"i--swI #",sw[i+a])
a +=1
except:
flag_sw = False
print("--empty---swI #")
try:
print(i,"i---crI #",cr[i+c])
c +=1
except:
try:
print(i,"i---dwI #",dw[i+b])
b +=1
except:
flag_dw = False
print("---dw array Empty dwI #")
# Ceramic
try:
print(i,"i---crII #",cr[i+c])
c +=1
except:
flag_cr = False
print("---empty crII #")
try:
print(i,"i---swII #",sw[i+a])
a +=1
except:
print("--- empty SWII---")
try:
print(i,"i---dwII #",dw[i+b])
b +=1
except:
flag_dw = False
print("--- empty dwII---")
# Double Weld
try:
print(i,"i--dwI3 #",dw[i+b])
b +=1
except:
print(i,"i--empty---dwI3 #")
b +=1
try:
print(i,"i---crI3 #",cr[i+c])
c +=1
except:
try:
print(i,"i---saI3 #", sw[i+a])
a +=1
except:
print("--empty-swI3 #")
# Again Single Weld
try:
#if flag_sw & flag_dw == False:
# a +=1
print(i,"i-- repeat swI4 #",sw[i+a])
except:
try:
#if flag_sw & flag_dw == False:
# c +=1
print(i,"i--repeat crI4 #",cr[i+c])
except:
try:
#if flag_sw & flag_c == False:
# b +=1
print(i,"i--repeat----dwI4 #",dw[i+b])
except:
print("---empty repeat dwI4 #")
print(" -- cycle ending {}--".format(i))
print("")
I'm trying to get output like
1,2,3,4
5,6,7,8
But sequence 6 and 7 are missing.
My current output is
1,2,3,4
5,8
Can anyone tell me where I went wrong?
|is the bitwise "or", not the logical "or". Not that it makes much difference here but...