Ask coding questions

← Back to all posts
Why does it keep not letting me write the data into the file users.txt?
Egghead21 (6)

I have tried many roundabout ways to allow me to write the list of usernames and passwords to the file Users.txt, but it won't work. Can anyone help me rewrite the file funcs.py and figure out a way to get it to write?

Answered by AlexanderBirabe (101) [earned 5 cycles]
View Answer
Comments
hotnewtop
MrEconomical (2277)

you dont need any special libraries

f = open("users.txt", "w+")
f.write("hello")
f.close()
Dart (1122)

@MrEconomical i needed this info too lol great that i just h appen to see this

Egghead21 (6)

@MrEconomical I need to try to put a local list and append that to the txt file, and it won't let me put a list directly into the txt file.

AlexanderBirabe (101)

Convert the list to a string

f = open("users.txt", "w+")
f.write(str(myList))
f.close()

@Egghead21

Egghead21 (6)

@AlexanderBirabe i didn't knwo it was that simple thanks