Simple "Contains" function in Python

Hi everybody,

I have written a basic Python script to check if titleblock family names contains either A1,A2,A3 etc. This works great.
When it comes to an item that I am not searching for however, it leaves that item out of the list completely… How do I tell it that if it does not equal one of the strings that I am searching for, it must just append the original item? The example is below:

Then when I put “else” at the end, it appends all of the items including the original as follows:

If an item does not match one of the searched fields, I just want the original item to be appended to the “newSize” list. Can anyone point me in the direction?

Thank you!

Hi @Sigma
try this:

result = []
for s in IN[0]:
	if 'A0' in s:
	elif 'A1' in s:
	elif 'A2' in s:
	elif 'A3' in s:
	elif 'A4' in s:
OUT = result


Perfect, thank you Kulkul, so it was just the elif instead of if… I will never forget that now :slight_smile:
Appreciate your help.