I am hoping to create a system for my game where the user is able to save some of their information into a file; however, I am unsure if I would be able to name the file after the name they input. ("james" becoming "james.txt" would be an example of what I would like to happen)
import pygame
def playerSave(playerName):
player = open("player1.txt", "w")
player.write("test")
player.close()
playerLoad()
def playerLoad():
player = open("player1.txt", "r")
message = player.read()
print (message)
player.close()
playerName = "james"
playerSave(playerName)
I am unsure how to do this but the above code shows what I have so far.
Any help is much appreciated :)