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))
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))
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.