By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

write array into txt python

P: 2
hello , i am waay new to python and programming.I'm trying to write program that stores username and password in txt but I don't seem to get what my problem is.

userName=str(raw_input ("Username :"))
passWord=str(raw_input("password : "))


stuData[userName ]=[passWord]
print stuData

May 5 '17 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 621
Expand|Select|Wrap|Line Numbers
  1. f=write(stuData)
  2. f=close() 
are not valid Python statements, see
You can only write text to a text file, not a dictionary, so one way is to write the user name, then the password separately, using a \n (newline) as deliminator.
May 5 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.