# Why is my code not working, i want it so that when points are added or taken away i want them to stay that way(python 3)

This is the code :

name = input("Welcome to the Math Game show I'm your one and only host Miles and what is your name? :")
print ("Nice to see you're here", name, "You will answer 10 questions in 3.....2.....1.....GOOOO!")
question1 = int(input("What is 9 + 10? :"))
points = int(0)
if question1 ==21:
print("correct here is ten points",points + 10)
elif question1 ==19:
print("correct here is ten points",points + 10)
else:
print("incorrect",points - 10, "points")
question2 = int(input("what is 25 x 6? :"))
if question2 ==150:
print("correct here is ten points",points + 10)
elif question2 ==21:
print("correct here is ten points",points + 10)
else :
print("incorrect",points - 10, "points")

this is the output it gave:

Welcome to the Math Game show I'm your one and only host Miles and what is your name? :Mj

Nice to see you're here Mj You will answer 10 questions in 3.....2.....1.....GOOOO!

What is 9 + 10? : 19

correct here is ten points 10

What is 25 x 6? :150

correct here is ten points

answered May 11 by (140 points)
Hi, to answer your question, the game doesn't save points because you're not actually updating them. Basically, when you go to print to increase the score by 10, you're just saying to print the value of the variable points, increasing it by 10. To solve the error I changed the variable containing the score before saying how much it is, and to visualize it a little better I added another line of print to display the total score. Of course you can modify the program to your liking to make it more similar to the idea you have in mind, but I hope I have been of help.

The code is this:

name = input("Welcome to the Math Game show I'm your one and only host Miles and what is your name? :")
print ("Nice to see you're here", name, "You will answer 10 questions in 3.....2.....1.....GOOOO!")
question1 = int(input("What is 9 + 10? :"))
points = int(0)
if question1 ==21:
points += 10
print("correct here is ten points: +10 points")
elif question1 ==19:
points += 10
print("correct here is ten points: +10 points")
else:
points -= 10
print("incorrect: -10 points")
question2 = int(input("what is 25 x 6? :"))
if question2 ==150:
points += 10
print("correct here is ten points: +10 points")
elif question2 ==21:
points += 10
print("correct here is ten points: +10")
else :
points -= 10
print("incorrect: -10 points")
+1 vote
answered May 11 by (79,800 points)
edited May 12 by Peter Minarik

To increase the points stored, you need to tell the compiler about the increment:

`points = points + 10`

or a shorthand version

`points += 10`

Then you can print it out, e.g.:

```if question2 == 150:
points += 10
print("Correct, here is ten points.")```

I'm also a bit confused about your logic, why do you grant scores for 9 + 10 = 21?

commented May 11 by (150 points)
Based on your logic, this should work but I don't understand why 21 should be correct for 10+9

name = input("Welcome to the Math Game show I'm your one and only host Miles and what is your name? :")
print ("Nice to see you're here", name, "You will answer 10 questions in 3.....2.....1.....GOOOO!")

question1 = int(input("What is 9 + 10? :"))
points = int(0)

if question1 == 21 or question1 == 19:
points += 10
print("correct here is ten points", points)
else:
points -= 10
print("incorrect", points, "points")

question2 = int(input("what is 25 x 6? :"))
if question2 == 150 or question2 == 21:
points += 10
print("correct here is ten points", points)
else :
points -= 10
print("incorrect", points, "points")
commented May 11 by (240 points)
edited May 11 by Malachi Johnson
i see why you are confused on that but that was as a joke for the 9+10 =21 meme
and thanks for the help i will try that
(Thanks so much you just helped me out a bunch thanks for your help!)
answered May 11 by (140 points)
name = input("Welcome to the Math Game show I'm your one and only host Miles and what is your name? :")
print ("Nice to see you're here", name, "You will answer 10 questions in 3.....2.....1.....GOOOO!")
question1 = int(input("What is 9 + 10? :"))
points = 0
if question1 ==21:
points+=10
print("correct here is ten points",points)
elif question1 ==19:
points+=10
print("correct here is ten points",points)
else:
points-=10
print("incorrect",points, "points")
print(points)
question2 = int(input("what is 25 x 6? :"))
if question2 ==150:
points+=10
print("correct here is ten points",points)
elif question2 ==21:
points+=10
print("correct here is ten points",points)
else :
points-=10
print("incorrect",points, "points")

this will give u the correct answer
answered May 12 by (150 points)
Based on your logic, this should work but I don't understand why 21 should be correct for 10+9

name = input("Welcome to the Math Game show I'm your one and only host Miles and what is your name? :")
print ("Nice to see you're here", name, "You will answer 10 questions in 3.....2.....1.....GOOOO!")

question1 = int(input("What is 9 + 10? :"))
points = int(0)

if question1 == 21 or question1 == 19:
points += 10
print("correct here is ten points", points)
else:
points -= 10
print("incorrect", points, "points")

question2 = int(input("what is 25 x 6? :"))
if question2 == 150 or question2 == 21:
points += 10
print("correct here is ten points", points)
else :
points -= 10
print("incorrect", points, "points")
answered Jun 14 by (250 points)

There is my code for reference:

name=str(input("Welcome to the Math Game show! I'm your one and the only host Miles! What is your name? "))
print('Nice to meet you,',name+'!')
a=eval(input("How many questions do you want? "))
list=['+','-','*']
point=0
question=0
for x in range (a):
import random
v1=str(random.randint(1,100))
v2=str(random.randint(1,100))
v3s=random.randint(0,2)
v3=list[v3s]
question+=1
print('Question',str(question)+': What is the answer of',v1+v3+v2,'?')
A=eval(input())
if v3=='*':
point+=20
print('Correct! Since this is a harder question, you just gained 20 points! You now have',point,'points.')
else:
point+=10
print('Correct! You just gained 10 points! You now have',point,'points.')
else:
point-=5