I have found the optimal solution:
To use def(x) it’s the best solution now. (loop)
list = ['enfj','enfp','entj','entp','esfj','esfp','estj','estp','infj','infp','intj','intp','isfj','isfp','istj','istp']
def get_label(path, list=list):
for psychoType in list:
if psychoType in path:
return psychoType
data["psychoType"] = data["path"].apply(get_label)
solved Python „stack overflow” (104 if statements). Is def(x) the only solution to optimise code?