def check_priority(): print(split("x*y+523*6+7")) cal=calculator() for x in split("x*y+523*6+7") cal.trans(x) print(cal.data_stack) print(cal.op_stack)
continue elif len(temp)==0 or is_one_word(temp[-1],x): temp+=x else: split_func.append(temp) temp=x if len(temp) != 0: split_func.append(temp) return split_func def calculate(split_func:list): for x in split_func: x=trans(x) if type(x)==int or float: data_stack.append(x) elif type(x)==str: if x =='('or')': op_stack.append(x) else: op_stack.append(op_dict[x]) print(split("x*y+523*6+7")) cal=calculator() '''for x in (split("x*y+523*6+7")) cal.trans(x) print(cal.data_stack) print(cal.op_stack)'''
return True elif (not l1.isalnum()) & (not l2.isalnum()): return True else: return False def split(func_str: str): temp = "" split_func = [] for x in func_str: if x == " ": continue elif len(temp) == 0 or is_one_word(temp[-1], x): temp += x else: split_func.append(temp) temp = x if len(temp) != 0: split_func.append(temp) return split_func temp = split("x+y+523+6+7") print(temp) cal = op.calculator() for x in temp: cal.trans(x) cal.print_data() cal.calculate()