0

I'm using python 2.7 and the code below:

def showScore(score):

    score = 1.5

    scoreKeeper = tk.Label(window, text=score)

    if (score >= 2.0)
    scoreKeeper.configure(text = "Too loud. Try again.") 

    scoreKeeper.pack()

I am getting the error

  File "tkinter_oqy01.py", line 18
    if (score >= 2.0)
                    ^
  SyntaxError: invalid syntax

and obviously can't figure out what it is.

1 Answer 1

2

You're missing a : in your if statement

Your if statement should be

if (score >= 2.0):

    scoreKeeper.configure(text = "Too loud. Try again.")

You're also checking if the score will be greater than two, but score will always be 1.5 since your setting score = 1.5 despite the score passed to the function.

score also isn't a string. So if you tried to run your program even after fixing that you'd get another error. you should be setting text = str(score)

Sign up to request clarification or add additional context in comments.

1 Comment

Oh duh. Missing a comma. Thank you, would have continued going crazy. I am changing the values of score manually for now to test the code. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.