0

So i am writing a program and i made a function which stores user data in a txt file.It is like a simple registration function.The user gives the username and password to store.Problem is i can't store user input in the file.

My code is :

def reguser(): #Function name. fwu = open('user.txt','w') #create or open user.txt file. user = input("Username: ") #takes the user input.e.g what username to register fwu.write(user) #this command should write input into the file fwp = open('pass.txt','w') #create or open pass.txt file. pas = input ("Password: ") #takes user input e.g what password to register fwp.write(pas) #write the password into the file print ("To check for registraion completion, please login.") askuser() 

So what i get is two text files user and pass but they are empty. What am i doing wrong?? and please do not tell me to use modules for registraion.

Regards ali7112001

0

2 Answers 2

1

You didn't fwu.close() or fwp.close() (you didn't save it). Also a quick look up next time would save you some time. .write not working in Python

Sign up to request clarification or add additional context in comments.

2 Comments

@MooningRawr thanks man
No worries! Just trying to save you time, save people time, more time saved = more time coding and doing other things.
0

Please try with raw_input() instead of input()

Also please close() the files.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.