You can create a sqlite database to store your points in:
```
import sqlite3
connection = sqlite3.connect("game.db")
cursor = connection.cursor()
cursor.execute("""
DROP TABLE IF EXISTS scoretable
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS scoretable (
playername TEXT NOT NULL,
score INTEGER NOT NULL
)
""")
connection.commit()
connection.close()
```
this will create a basic table storing players names and their score.
```
playername = input("Type in playername: ")
# If player is new a new row is added to the db
newgame = input("Newgame? yes or no? ")
if newgame == "yes":
cursor.execute("INSERT INTO scoretable (playername,score) VALUES (?,?)", (playername,1))
# reads current players score from the db
cursor.execute("SELECT score FROM scoretable WHERE playername = ?", [playername])
result = cursor.fetchone()
a = result[0]
print(a)
b = input("c or d")
if b == "c":
a += 1
if b == "d":
a -= 1
print(f"you have {a} points")
# stores current players score in the db
cursor.execute("UPDATE scoretable set score = ? WHERE playername = ?", (a,playername))
connection.commit()
connection.close()
```
I have added some basic storing points mechanics to your game.
This is only a starting point as you could flesh this out way further.
You can create a sqlite database to store your points in:
```
import sqlite3
connection = sqlite3.connect("game.db")
cursor = connection.cursor()
cursor.execute("""
DROP TABLE IF EXISTS scoretable
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS scoretable (
playername TEXT NOT NULL,
score INTEGER NOT NULL
)
""")
connection.commit()
connection.close()
```
this will create a basic table storing players names and their score.
```
playername = input("Type in playername: ")
# If player is new a new row is added to the db
newgame = input("Newgame? yes or no? ")
if newgame == "yes":
cursor.execute("INSERT INTO scoretable (playername,score) VALUES (?,?)", (playername,1))
# reads current players score from the db
cursor.execute("SELECT score FROM scoretable WHERE playername = ?", [playername])
result = cursor.fetchone()
a = result[0]
print(a)
b = input("c or d")
if b == "c":
a += 1
if b == "d":
a -= 1
print(f"you have {a} points")
# stores current players score in the db
cursor.execute("UPDATE scoretable set score = ? WHERE playername = ?", (a,playername))
connection.commit()
connection.close()
```
I have added some basic storing points mechanics to your game.
This is only a starting point as you could flesh this out way further.