'I cant pass a variable in pyrebase, even though it has the string form
Im making a game in python and i want to save the high score of a certain account to firebase. However, this code doesnt work, unless instead of writing f'{username}', i write the name i want (for example "gamer123"). Also, the set part isnt being recognized as json.
def signup():
global high_score
layout1=[
[ps.Text("Username: "), ps.Input(key="username", do_not_clear=False)],
[ps.Text("Password: "), ps.Input(key="password", password_char="*", do_not_clear=False)],
[ps.Button("Signup")]
]
janela=ps.Window("Signup", layout1)
while True:
eventos,valores=janela.read()
if eventos==ps.WINDOW_CLOSED:
break
if eventos=="Signup":
username=valores["username"]
password=valores["password"]
try:
user=auth.create_user_with_email_and_password(username, password)
ps.popup("Account created successfully!")
janela.close()
db.child('Users').child(f'{username}').set(f'{{"high score": {high_score}}}')
menu()
except:
janela.close()
ps.popup("Username already exists!")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
