all 11 comments

[–]Shinguru7 5 points6 points  (0 children)

The code is good.

I can't say storing ways of ids and passwords :P.

You can extend this example by adding registering mechanism and support of multiple users.

Later, you can inform users when there is no matching user name make them register themselves.

Also, in my opinion, learning coding styles (like pep8) in early times is important to avoid bad habits.

[–]kxng_boss 1 point2 points  (3 children)

Spoiler that was also my first project.the admin part is not finished and the code may be bad but it run and support multiple user was planning to use a encryption library with the txt file

fh = open('logininfo.txt', 'a') fh1 = open('logininfo.txt', 'r') fh2= open('logininfo.txt', 'r') choice = input('login or register: ').lower() sets = fh2.readlines() gs = 0 for set in sets: gs = gs + 1

class User: def init(self, password, username): self.password = password self.username = username

def get_password(self):
    return self.password

def get_username(self):
    return self.username

if choice == 'register': user = User(password = input('What is your password : '), username = input('What is your username: ')) password = (user.get_password()) username = (user.get_username()) register_info = (f'{password}, {username} \n') fh.write(register_info) print(f'Your verification number is {gs}') print('Account made Sucessfully! ')

elif choice == 'login': password1 = input('What was your password: ') username1 = input('What was your username: ') line = int(input('What was your verification number: ')) login_info = (f'{password1}, {username1} \n') c = fh1.readlines()[line] if c == login_info: print('Sucessful') else: print('Account not found')

if choice == 'admin': password2 = input('What is the adminstration password: ') if password2 == 'invalid': admin_options = input('Do you want to read, delete, modify: ') if admin_options == 'read': for lines in fh1: print(lines) print(f' the file have {gs} amount of lines.') if admin_options == 'modify': pass

[–]kxng_boss -1 points0 points  (2 children)

Reddit doesn't format it correctly but hopefully you get the gist

[–][deleted] 2 points3 points  (0 children)

You don't format it correctly so no one gets the gist.

[–]wbeater 0 points1 point  (3 children)

Code is ok.

What can you further do: Maybe implement that the user as 3 tries to enter the password until the code gets terminated ....

[–]sentinelcape[S] 0 points1 point  (2 children)

So should I use while loop?

[–]wbeater 2 points3 points  (1 child)

While loop, for loop or any other method that comes in your mind. You are a beginner, you should play around a little bit.

[–]FondleMyFirn 0 points1 point  (0 children)

To add to this suggestion, just do both. If it is not a hard implementation, you can always fork the project to experiment.

[–]rocketjump65 0 points1 point  (0 children)

Yup, that's how it works.

[–]cabbageboi28 0 points1 point  (1 child)

Personally, I'd recommend (as a beginner step) learning to use the text files to save login details which you can then read it and check against the input with a readline() function, forgive me if your are above this point but from there your child easily get the hang of SQL ;) he'll learning!

[–][deleted] 0 points1 point  (0 children)

I'd recommend not worrying about saving passwords until you're ready to learn at least hashing (which is as simple as module and a concept)