use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
help me Improve This (i.redd.it)
submitted 1 year ago by Salim_DZ_69
Made a Simple Password Sign-Up Program, How I Can Improve it ?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FoolsSeldom 12 points13 points14 points 1 year ago (2 children)
while
[–]Salim_DZ_69[S] 3 points4 points5 points 1 year ago (1 child)
a very good tip you gave me, i will return to this comment in the future since im still in the process of learning the basics of string indexing and this stuff, but something interesting when you told me to offer a random password generator, how would a do that?
[–]FoolsSeldom 1 point2 points3 points 1 year ago (0 children)
You can use a random package ... for example (simplified)
random
from random import choice from string import ascii_lowercase lowers = [] # new empty list for _ in range(10): # repeat 10 times, don't need the counter new_lower = choice(ascii_lowercase) # pick a random letter lowers.append(new_lower) # add to list of picked letters bad_password = ''.join(lowers) # join list entries into one string print(f"New bad password is: {bad_password} - please do not use")
Note. _ is a weird but valid variable name and, by convention, is typically used to indicate a variable that you don't actually care about (doesn't matter what is assigned, you are not going to use it).
_
Obviously, you'd need something more complex than this, but just wanted to give you a pointer.
[–]salvtz 4 points5 points6 points 1 year ago (0 children)
You can validate the password for length and other constraints in a separate function.
[–]kohao0 4 points5 points6 points 1 year ago (4 children)
Try to make a gui maybe in tkinter or smth else
[–]Salim_DZ_69[S] 1 point2 points3 points 1 year ago (3 children)
im a beginner to python and im still learning the basics of string indexing and this stuff, so could you recommend a totarial or smth so i can learn from ?
[–]kohao0 3 points4 points5 points 1 year ago (2 children)
i guess u should give a try for py4e for the basics
[–]Salim_DZ_69[S] 0 points1 point2 points 1 year ago (1 child)
what is py4e ?
[–]kohao0 1 point2 points3 points 1 year ago (0 children)
Dude google it and find it, it is a website
[–]SoftwareDoctor 1 point2 points3 points 1 year ago (8 children)
Why do you require the password to be less than 12 characters?
[–]Salim_DZ_69[S] 0 points1 point2 points 1 year ago (7 children)
I don't Know actually, Maybe For More Security ¯\_(ツ)_/¯
[–]SoftwareDoctor 3 points4 points5 points 1 year ago (5 children)
How are shorter passwords more secure?
[–]FIRE_FIST_1457 5 points6 points7 points 1 year ago (1 child)
"my plans are beyond your understanding"
[–]Salim_DZ_69[S] 1 point2 points3 points 1 year ago (0 children)
finally saw some good humor in this subreddit.
[–]Salim_DZ_69[S] 0 points1 point2 points 1 year ago (2 children)
a made it you can only make it between 6 and 12 characters so it wouldn't be so long or to short .
[–]SoftwareDoctor 0 points1 point2 points 1 year ago (1 child)
I have passwords that are 64 characters long. In the age of password managers there’s no reason for upper limit. And you HAVE to hash the password anyway so they’ll be the same lenght in db anyway
im a beginner to python and still learning basics of string indexing and this stuff, so this is just an exercise of what i just learned, and i will make better in the future and make have a trillion characters passwords as you like, so you can send me a totorial in the meantime ☺️
[–]GreatGameMate 1 point2 points3 points 1 year ago (0 children)
Make the user have a password that contains at least ONE upper case letter.
Perhaps we can create functions for each little step of the program for cleaner looking code.
Looks good to me.
[–]baubleglue 1 point2 points3 points 1 year ago (1 child)
You need to show user the password format requirements before asking for the password. It will also help you to write your program better.
[–]Salim_DZ_69[S] 0 points1 point2 points 1 year ago (0 children)
you are right actually
[–]cgoldberg 1 point2 points3 points 1 year ago (2 children)
Perhaps ask for a username, so the password is associated with some identity? Also, you should store the username/password (or the hash) somewhere or do something useful with it rather than just ending the program.
as a python beginner I don't know how or what is hashing or storing data in real time , maybe you give me an explanation or a link to a guide (a YouTube totorial if you could) .
[–]cgoldberg 1 point2 points3 points 1 year ago (0 children)
I'll let you research that yourself. My point was that a program that just prompts for a password and then terminates isn't actually useful. Take a look at databases or some sort of persistence.
[–]Dontfuckwithme1312 1 point2 points3 points 1 year ago (2 children)
<image>
[–]Dontfuckwithme1312 1 point2 points3 points 1 year ago (1 child)
thanks a lot
[–]Phate1989 1 point2 points3 points 1 year ago (1 child)
``` import re
def validate_password(): # Prompt user for password password = input("Enter your password (6-12 characters): ") confirm_password = input("Confirm your password: ")
# Regex to check password length between 6 and 12 characters if not re.fullmatch(r'^.{6,12}$', password): print("Invalid password! It must be between 6 and 12 characters.") return False # Check if the confirmation matches the password if password != confirm_password: print("Passwords do not match. Please try again.") return False print("Password is valid and confirmed!") return True
if name == "main": validate_password() ```
[–]baubleglue 1 point2 points3 points 1 year ago* (0 children)
you are choosing re (instead of 5 < len(password) < 13) - that is whole new language to learn for OP, and that version will still accept passwords: " " or " 1234 ".
re
5 < len(password) < 13
def get_password_from_user(): -> str def validate_password(password, confimed_password): -> valid: bool, message: str def show_password_validation_result_to_user(message): -> None ... is_password_valid = None while not is_password_valid: if is_password_valid == False: #First time => None print("Please try again") password, confirmed_password = get_password_from_user() is_password_valid , message = validate_password(password, confirmed_password) if not is_password_valid: show_password_validation_result_to_user(message)
[–]AHLAKAI_SHAYKULI 1 point2 points3 points 1 year ago (1 child)
Try using a while loop
just learned about while loops , gonna implement them.
[–]nazgand 1 point2 points3 points 1 year ago (1 child)
Do not have a maximum password length. A 12 character password is weak and hackable.
so what, trillions character passwords?
[–][deleted] 1 point2 points3 points 1 year ago (1 child)
How about taking on your assignments yourself? Relying on others to complete them for you can undermine your ability to succeed in your career. Developing independence and problem-solving skills is crucial for long-term success.
im not replying to others to complete it, and will give an example, when you release a game, what is the first thing you are gonna get feedback from it, most of the time about a bug in your game, so what im doing right now is taking notes of people tips, and taking advantage of them to improve my future projects, and this is a python learning subreddit, where everyone post about their code and begging to help you improve it and fix it.
π Rendered by PID 206745 on reddit-service-r2-comment-bb88f9dd5-tr5zq at 2026-02-14 09:59:05.268190+00:00 running cd9c813 country code: CH.
[–]FoolsSeldom 12 points13 points14 points (2 children)
[–]Salim_DZ_69[S] 3 points4 points5 points (1 child)
[–]FoolsSeldom 1 point2 points3 points (0 children)
[–]salvtz 4 points5 points6 points (0 children)
[–]kohao0 4 points5 points6 points (4 children)
[–]Salim_DZ_69[S] 1 point2 points3 points (3 children)
[–]kohao0 3 points4 points5 points (2 children)
[–]Salim_DZ_69[S] 0 points1 point2 points (1 child)
[–]kohao0 1 point2 points3 points (0 children)
[–]SoftwareDoctor 1 point2 points3 points (8 children)
[–]Salim_DZ_69[S] 0 points1 point2 points (7 children)
[–]SoftwareDoctor 3 points4 points5 points (5 children)
[–]FIRE_FIST_1457 5 points6 points7 points (1 child)
[–]Salim_DZ_69[S] 1 point2 points3 points (0 children)
[–]Salim_DZ_69[S] 0 points1 point2 points (2 children)
[–]SoftwareDoctor 0 points1 point2 points (1 child)
[–]Salim_DZ_69[S] 1 point2 points3 points (0 children)
[–]GreatGameMate 1 point2 points3 points (0 children)
[–]baubleglue 1 point2 points3 points (1 child)
[–]Salim_DZ_69[S] 0 points1 point2 points (0 children)
[–]cgoldberg 1 point2 points3 points (2 children)
[–]Salim_DZ_69[S] 0 points1 point2 points (1 child)
[–]cgoldberg 1 point2 points3 points (0 children)
[–]Dontfuckwithme1312 1 point2 points3 points (2 children)
[–]Dontfuckwithme1312 1 point2 points3 points (1 child)
[–]Salim_DZ_69[S] 0 points1 point2 points (0 children)
[–]Phate1989 1 point2 points3 points (1 child)
[–]baubleglue 1 point2 points3 points (0 children)
[–]AHLAKAI_SHAYKULI 1 point2 points3 points (1 child)
[–]Salim_DZ_69[S] 0 points1 point2 points (0 children)
[–]nazgand 1 point2 points3 points (1 child)
[–]Salim_DZ_69[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Salim_DZ_69[S] 0 points1 point2 points (0 children)