I'm pretty new to Python and I'm trying to make a discord bot using discord.py and the idea is that you can earn coins that are showed on your profile. The problem is that I need to store the profiles in a single file so it looks like this
userID1,10
userID2,20
userID3,30
Expected output:
userID1,10
userID2,120
userID3,30
Basically "discord id of a user,amount of coins" and I'm trying to replace the line but with a different amount of coins and I have no idea on how to do this without making another file.
This is all I have right now.
def addExp(userID,Points):
with open(fname) as f:
for line in f:
if userID in line:
info = line.split(',')
newPoints= int(info[1]) + Points
UserID is the ID of an user so it's different for each user and Points is the amount of points I want to add