stack

    0

    0

    gokul vedullapalli

    The code above will create an anonymous list of strings with the following elements:

    || "or" && "and" == "is", ">=", "<=", "<", ">", "!"

    
    lis_oper = []
      lis_ele = []
      cur_lis = dic[id]
      for i in range(len(cur_lis)):
        if cur_lis[i] in ["||", "&&"]:
          lis_oper.append(cur_lis[i])
        elif cur_lis[i] in ["==", ">=", "<=", "<", ">", "!="]:
          lis_ele.append(evulate(cur_lis[i - 1], cur_lis[i], cur_lis[i + 1]))
      i = 1
      str_ = str(lis_ele[0])
      if len(lis_oper) == 1:
        while len(lis_oper) != 0:
          if i % 2 == 1:
            if lis_oper[0] == "||":
              str_ += "  or "
            elif lis_oper[0] == "&&":
              str_ += "  and "
            lis_oper = lis_oper[1:]
          else:
            str_ += str(lis_ele[0])
            lis_ele = lis_ele[1:]
          i += 1
        str_ += str(lis_ele[0])
      if len(str_) == 4 or len(str_) == 5:
        return bool(str_)
      else:
        return eval(str_)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.