Skip to content Skip to sidebar Skip to footer

Python „stack Overflow” (104 If Statements). Is Def(x) The Only Solution To Optimise Code?

Today have tried to check files with path directory name. Previously it worked, until I tried to create 104 if/else statements. How to dispose of this overflow error? More specifi

Solution 1:

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)

Post a Comment for "Python „stack Overflow” (104 If Statements). Is Def(x) The Only Solution To Optimise Code?"