In the following code I'm trying to check if the variable "new_shape" already exists within "shape_list". If it does not exist already, I want to add it; if it does exist, I just want to leave it. So far, I have only achieved this using flags. I'm sure there's a way to accomplish the same thing more efficiently without flags. Any suggestions? Thanks for any help you give!
flag = 0
for shape in shape_list:
if new_shape == shape:
flag = 1
break
if flag == 0:
shape_list.append(new_shape)
You can use