OS Windows Python 3(onlinegdb.com)
при выполнении кода появляется ошибка я пытался исправить, но не получилось...
Python:
#alchimic the game v1.0
from sqlite3 import *
#создание таблиц и добавление базовых значений
conn = connect('money.db')
cur = conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS money(money INT )')
cur.execute("""CREATE TABLE IF NOT EXISTS event(
addi INT,
res INT,
dec INT)""")
conn.commit()
cur.execute("""INSERT INTO money(money)
VALUES(0);""")
cur.execute("""INSERT INTO event(addi,res,dec)
VALUES(5,0,0)""")
conn.commit()
cur.execute("SELECT * FROM money")
money = cur.fetchone()[0]
cur.execute("SELECT * FROM event")
table = cur.fetchone()
add = table[0]
res = table[1]
dec = table[2]
#функции для обновлений данных в таблицах
def change (add1, res1, dec1):
change1 = """
UPDATE event
SET addi = add1
WHERE addi = add
SET res = res1
WHERE res = res
SET dec = dec1
WHERE dec = dec
"""
cur.execute(change1)
conn.commit()
def money0(money3):
money2 = """
UPDATE money
SET money = money3
WHERE money = money
"""
cur.execute(money2)
conn.commit()
#основные переменные
while True:
a_s = False
a_tree = None
a_fruit = 0
balance = money+add+res-dec
money0(balance)
#основная игра
print("Let's Start game!!!\n")
print("enter buy to buy plants!")
print("enter sell to sell you plants!")
print("enter care to look after you plants!")
c_game = input("enter command: ")
if c_game == "buy":
print("you have " + str(balance) + "$")
print("We have: 1.Apple Tree $5, ")
choice = input("select plant: ")
if choice == str(1):
a_s = True
change(5,0,5)
print("you buy an apple tree!")
else:
print("I don't know this command... Return")
elif c_game == "exit":
break
else:
print("I don't know this command... Return")