Skip to content
Sign upLog in
← Back to Community
Saving a score to put in displayIntro in python?
Profile icon
erger561

How do you save something that is before displayIntro() and then put it in displayIntro() with the same value?

Voters
Profile icon
lolguineapig
Comments
hotnewtop
Profile icon
lolguineapig

@erger561
are you saying that you have a variable defined outside the function, and you want it to be defined in the function with the same value? If yes, you just have to use the keyword global.
Example:

var = input("What is your favorite color?") def hello(): return "Hello user. " + var + "is your favorite color!" print(hello())

That won't work ^
but this code will:

var = input("What is your favorite color?") def hello(): global var return "Hello user. " + var + "is your favorite color!" print(hello())
Profile icon
erger561

What I am saying is that I want the points to be in the displayIntro() with the same value as before the displayIntro()

Profile icon
erger561

Never mind, I think I know how to know.

Profile icon
erger561

If you do not understand what I am saying plat the code, so chose a game type what it says for you to type slots or spinandwin and then after you earn some points switch the game and it will say it does not know what points is.

Profile icon
erger561

In this case it is points that I need to save.