[Python] How to save data in Pygame

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    What I want to do is to save a variable when I run the code again

    Code:

    a = 1
    b = input("c or d")
    if b == "c":
    a += 1
    print(f"you have {a} points")
    if b == "d":
    a -= 1
    print(f"you have {a} points")


    Still confused? The first time I run this, if I respond with "c", then the output should be "you have 2 points", the next time I run this and respond with "c", the output should be "you have 3 points". I tried to find tutorials but none of them were useful. Share the code here if you solve the issue

    IMPORTANT:

    1. I use PyCharm
    2. Add the code along with your answer

    Continue reading...

Compartilhe esta Página