I have created a quiz game in Python that also contains a login and register program however I'm trying to add a scoring system.
Currently, I have the CSV file set out like this:
username,password,score
When you create an account the score is set to 0 and is loaded when you log in using:
for row in users:
if username == row[0]:
currentScore = row[2]
currentScore = int((currentScore))
This grabs the users high score from the CSV file. However when a game finishes I have this setup to determine if their new score is higher than there old score or not:
if int(score) > int(currentScore):
currentscore = score
I then need it to open the database and find the user that is playing and update there score with the new one. How would I do this? I have tried to get csv to edit a certain row but it doesn't seem to work.
Full code can be found here:https://pastebin.com/q07qazJA
then need it to open the database, and which database would that be? a csv isn't a database, why not just usesqlitesince it comes in the standard lib. will make your life a whole lot easier..jsonfile. You can treat the data as a dict instead of needing to loop through all the data. A dict is hashed allowing for easier lookups, otherwise I'd suggest using pandas to make your life easier with the csv file.