-1

why do I get this problem: SyntaxError: EOL while scanning string literal. Can someone please tell me where my fault is.

a = 2
b = 4
c = 8
print ("Forced Order:" 'a', '*' ('c' '+' 'b') '=’ a*(c+b))
  • 1
    As written, your quotation marks are not properly balanced. What you _actually_ wanted to do was to [insert variable values into a string](https://stackoverflow.com/questions/2960772/how-do-i-put-a-variable-inside-a-string-in-python). – DYZ Jan 03 '19 at 06:28

1 Answers1

0

The EOL error specifically appears because of '*' ('c' '+' 'b'). The computer believes that this code is trying to run a function, much like print(). The error pops up because a string cannot call a function like this.

What I imagine your trying to do is make the function output is Forced Order: a*(c+b)=24.That can be solved with two quick fixes:

First, there's a typo. '=’ should use ' not on both sides.

Second, the parenthesis need to be parts of the string. The parenthesis in ('c' '+' 'b') are not part of any strings. Either they can be individually turned into strings like the rest of the function or, just like with the string "Forced Order:", the string "a*(c+b)" can be written out as one string instead of concatenating a series of single characters.

SuperDyl
  • 40
  • 1
  • 8