I have some elements each has some attribute
Example:
a1 = Quadrupole(Name= 'qd1.1', Length = 2.9)
Some of them had additional attribute called R1:
a2 = Quadrupole(Name= 'qd1.1', Length = 2.9, R1=some value)
I want to loop through this element and append the attribute R, first i got the error "'Quadrupole' object has no attribute 'R1'" for the elements that don't have the attribute, i want to append zero value for these elements, i want to implement something like:
i = 0
while (i < len(elements_indexes)):
if (a[i].FamName).startswith('q') and a[i].R1 exist:
skew_quad_coof = a[i].R1
else:
skew_quad_coof = 0
k_qs.append(skew_quad_coof)
i += 1
However, this did not work