So here is my code(I translated it from german, so if there are some weird words, they might be german):
import random
import string
coolThings = list(string.ascii_letters).append(list(string.digits))
PASSWORD = "a password"
passCheck = input("Enter your password:\n>")
while passCheck != PASSWORD:
print("Wrong password, try again")
passCheck = input("Enter your password:\n>")
def S():
passes = open("passes.txt", "r")
print("Your passwords: ")
print(passes.read())
passes.close()
def A():
passa = ""
name = input("How should your new password be called?\n>")
for x in range(12):
passa += random.choice(coolThings)
passes = open("passes.txt", "w")
passes.write(name + " : " + passa)
passes.close()
def D():
pass
def E():
pass
def Choice():
print("What do you want to do?")
print("See passwords: S")
print("Add a password: A")
print("Delete a password: D")
print("Delete all: E")
choice = input(">")
return auswahl
userChoice = Choice()
if userChoice == "S":
S()
elif userChoice == "A":
A()
elif userChoice == "D":
D()
elif userChoice == "E":
E()
I know, i know. Im new to programming and I will be changing the function names later.
But thats my error:
Traceback (most recent call last):
File "d:/Programme/Passwörter Speichern/passwords.py", line 45, in <module>
A()
File "d:/Programme/Passwörter Speichern/passwords.py", line 23, in A
passa += choice(coolThings)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\lib\random.py", line 288, in choice
i = self._randbelow(len(seq))
TypeError: object of type 'NoneType' has no len()
If someone could help me, it would be very helpful. I know for sure that it has to do something with the random choice() funtion. ;)
Aucun commentaire:
Enregistrer un commentaire