I neeed help plzzz
This is for a school project and it is saying there is a syntax error when I think there is nothing wrong could I please get some help fixing it?
To further elaborate.
(score + 1) simply returns whatever score plus one is, for example, if score is 2, (score + 1) evaluates to 3.
However, this does not actually set score to 3. It only evaluates to 3, so for example
(score + 1) == 3 would be true, however
score == 3 would be false.
In order to add 1 to score and to set it to the new value, which is called incrementing, you need to set the score to itself plus 1.
The obvious way is
score = score + 1, however in Python (and most other languages), you can actually shorten it to
score += 1.
*= also exist.
I am going to mark @IMayBeMe as the answer.
@PythonLearner99 Ok so the issue on the else statement is that your code looks like this,
else: print("You are wrong."), but in reality the issue is the and
else: statement can't be on the same line as function your calling which in this case is
print("You are wrong.") So to fix this you would put the print on the next line and indnet it like so:
else: print('You are worng.')
Also on a side note if you were wondering about the single quotes on the correct code which I put, its just a faster way of putting quotes in python