Ask coding questions

← Back to all posts
How do you turn a string variable to a int?
CoderSloth909 (1)

I searched it up on youtube and it is showing me what I already know. I know how to turn input into an int, just not a variable. I want to add points to my game, but I can not add them up, it just stays at zero, do you know how to help me??
this is what I do
points = 0
blah blah a bunch of code
points + 1

I thought it was right, but it was not, and I know what is wrong, I know what to do (That is turn "points" into an int) but I do not know how to do it... :( Can anyone help me??? Please?

Answered by Dunce (70) [earned 5 cycles]
View Answer
Comments
hotnewtop
Dunce (70)

It's just points = int(points). And you should actually be doing either
points = points + 1 or points += 1.

Coder100 (18253)

you never assigned the variable points remember? You have to assign the variable, 1+points just calculates the expression, but doesn't do anything with it!

points += 1

or

points = points + 1
CoderSloth909 (1)

Thank all of you for your help!

LukeWright (287)

If you are trying to add 1 to the points, you would do

points += 1

instead of

points + 1

this is basically the abbreviated version of

points = points + 1
CoderSloth909 (1)

for the second question, you have to put joker, instead of THE joker.