0

Someone please help me with my python password generator!

I want my password generator to create a .txt file and save my passwords there, but it won't. Why? https://code.sololearn.com/ck2uaDEkJ31s

26th Dec 2019, 9:27 PM
Ville Nordström
Ville Nordström - avatar
10 Respostas
+ 5
I have found the problem: In, line 22, "file = file.open("pass.txt", "w")", your code is using the undefined variable "file", so it displays an error. To fix this, you have to replace "file.open()" with "open()". Also, you should try to use "with" instead so the file is automatically closed and because it's more efficient. Answer: Change, line 22, "file = file.open("pass.txt", "w")" with "file = open("pass.txt", "w")" Recommendation: Use "with" instead, which looks like: with open("pass.txt", "w") as f: f.write(Password) f.close()
26th Dec 2019, 9:47 PM
SoundInfinity
SoundInfinity - avatar
+ 4
CR34TUR3 I think import module don t work in sololearn. I mean playground
26th Dec 2019, 9:37 PM
Petr
+ 4
SoundInfinity I can input 2 numbers :)) by "enter"
26th Dec 2019, 9:49 PM
Petr
+ 1
The program works fine. I got a PW 😀
26th Dec 2019, 9:55 PM
Coding Cat
Coding Cat - avatar
+ 1
But file. open will not work on Playground!
26th Dec 2019, 9:55 PM
Coding Cat
Coding Cat - avatar
+ 1
Petr Yeah, I realized that, I didn't know that could be done. So, I assumed that you couldn't send 2 inputs.
26th Dec 2019, 9:57 PM
SoundInfinity
SoundInfinity - avatar
0
An other question is why do you want to save it in a file
26th Dec 2019, 9:56 PM
Nico Ruder
Nico Ruder - avatar
0
Maybe it runs with pydroid3 on your mobile
26th Dec 2019, 9:56 PM
Coding Cat
Coding Cat - avatar
0
But then you have to choise a valid folder for your file
26th Dec 2019, 9:57 PM
Coding Cat
Coding Cat - avatar
0
Thank you Soundifinity!
26th Dec 2019, 10:06 PM
Ville Nordström
Ville Nordström - avatar