write array into txt python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lolipoli
    New Member
    • May 2017
    • 2

    write array into txt python

    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(ra w_input ("Username :"))
    passWord=str(ra w_input("passwo rd : "))

    stuData={}


    stuData[userName ]=[passWord]
    print stuData

    f=open("student .txt","a")
    f=write(stuData )
    f=close()
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Code:
    f=write(stuData)
    f=close()
    are not valid Python statements, see https://www.tutorialspoint.com/pytho...n_files_io.htm
    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.

    Comment

    Working...