I am trying to ask the user what they want to name a file that is about to be created on my desktop. When I try to add the variable to the string, it gives me this error:
appendFile = open('%s.txt', 'a') % cusername
TypeError: unsupported operand type(s) for %: '_io.TextIOWrapper' and 'str'
Here is my program:
def CNA():
    cusername = input("Create username\n>>")
    filehandler = open("C:/Users/CJ Peine/Desktop/%s.txt", "w") % cusername
    filehandler.close()
    cpassword = input("Create password\n>>")
    appendFile = open('%s.txt', 'a') % cusername
    appendFile.write(cpassword)
    appendFile.close()
    print ("Account Created")
How do I make the variable compatible to the string?
 
     
    