-4

I want to make a python script that finds the maximum possible output using 2 operations. The problem it says that there is a syntax error at the 2nd to the last line, in the b in there. How can I fix it?

x = 0
a = int(input("1st number:")) 
c = int(input("2nd number:" )) 
e = int(input("3rd number:" ))
for i in range(4):
    if i == 0:
        b = "+" 
    elif i == 1: 
        b = "-"
    elif i == 2:    
        b = "/"
    else:
        b = "*" 
    for j in range(4):
        if j == 0:
            d = "+" 
        elif j == 1: 
            d = "-" 
        elif j == 2:    
            d = "/" 
        else:
            d = "*" 
        k = a b c d e
        print(k) 
user8214698
  • 1
  • 1
  • 2

2 Answers2

-1

If all you're after is the variables a to e on a single line, couldn't you just separate them with commas and call Print?

Print a,b,c,d,e
neophlegm
  • 375
  • 1
  • 13
-2

k = a b c d e would give you error because this is not permitted. You could do it like:

if b == "+" and d == "+":
    k = a + c + e
elif b == "+" and d == "-":
    k = a + c - e

And etc.

Petar Toshev
  • 67
  • 1
  • 1
  • 9
  • That won't fix anything. Firstly, because Python doesn't do scopes inside if statement and for loops, and secondly because the problem is that `a b c d e` is invalid syntax, not a case of a name error. – Izaak van Dongen Aug 20 '17 at 23:08