大佬们,横向的输出应该怎么做?

def arithmetic_arranger(x):
    len1 = len(x)
    i = 0
    for y in range(len1):
        str1 = x[i]
        line = str1.split(' ')
        a = line[0]
        b = line[2]
        c = line[1]
        i = i + 1
        if c == "+" or c == "-":
            pass
        else:
            print("Error: Operator must be '+' or '-'")
            break
        while True:
            if c == "+":
                num = int(a) + int(b)
            else:
                num = int(a) - int(b)
            break
        print("{:>10}".format(a))
        print("{:<}".format(c), "{:>8}".format(b))
        print("{:->11s}".format(""))
        print("{:>10}".format(num))
        print("")


arithmetic_arranger(["32 + 698", "1 * 3081", "9999 + 9999", "523 - 49"])

You need to use return

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.