79150368

Date: 2024-11-02 09:45:52
Score: 2.5
Natty:
Report link

How about using a parsing function and matching on the return value? For example:

def get_operator(token_list):
    if '/' in token_list:
        return '/'
    ...
    return 'NUM'  # 'NUM' means numeric token 

match get_operator(c):
    case '/':
        i = c.index("/")
        before_div, after_div = c[:i], c[i+1:]
        ...
    case "NUM":
        return c[0]
Reasons:
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): How
  • Low reputation (0.5):
Posted by: olives