-2
PlayerAnswer = easygui.enterbox ("What is" +Figure1+ "+" +Figure2+ "?")

This line of code is not reading, both Figure1 and Figure2 are defined as random variables, and the random module is imported.

Here is how I've defined them at the top of the code:

Figure1 = random.randrange(0,11)
Figure2 = random.randrange(0,11)

The error I get is:

TypeError: cannot concatenate 'str' and 'int' objects**

Here is the coding in context:

for number in range(0,11):
    PlayerAnswer = easygui.enterbox ("What is" +Figure1+ "+" +Figure2+ "?")
    if PlayerAnswer ==(Figure1 + Figure2):
            AdditionAnswers += 1
            easygui.msgbox ("Correct! Your score is "+str(AdditionAnswers))**
pppery
  • 3,731
  • 22
  • 33
  • 46
Char
  • 7
  • 1
  • 5

1 Answers1

1

You can't add values with types that are of a string and an integer together. In order to make this work properly, you need to convert the two values to strings using the str function, like this:

PlayerAnswer = easygui.enterbox ("What is" + str(Figure1) + "+" + str(Figure2) + "?")
Ethan Bierlein
  • 3,353
  • 4
  • 28
  • 42