Python Password Generator Project (EASY)🐍

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ธ.ค. 2024

ความคิดเห็น • 7

  • @YousefCompSci
    @YousefCompSci  3 วันที่ผ่านมา +3

    import random
    import string
    def generate_pasword(length):
    characters = string.ascii_letters + string.digits + string.punctuation
    password = ''.join(random.choice(characters) for _ in range(length))
    return password
    while True:
    length = int(input("Enter a password length (or 0 to exit): "))
    if length == 0:
    break
    print(f"Generated password: {generate_pasword(length)}")

    • @eddiemeddie2018
      @eddiemeddie2018 วันที่ผ่านมา +1

      You are awesome for showing us this project. Thanks for the video!

    • @YousefCompSci
      @YousefCompSci  14 ชั่วโมงที่ผ่านมา

      @@eddiemeddie2018 my pleasure; thanks for the comment!

  • @Monsta1291
    @Monsta1291 3 วันที่ผ่านมา +1

  • @yousef.ls3
    @yousef.ls3 3 วันที่ผ่านมา +1

  • @AnuragS10
    @AnuragS10 วันที่ผ่านมา +1

    def generatePassword(length):
    characters = string.ascii_letters + string.digits + string.punctuation
    while True: # Keep generating until the password meets the criteria
    password = ''.join(random.choice(characters) for i in range(length))
    if (any(c.islower() for c in password) # At least one lowercase letter
    and any(c.isupper() for c in password) # At least one uppercase letter
    and any(c.isdigit() for c in password) # At least one digit
    and any(c in string.punctuation for c in password)): # At least one special character
    return password

    while True:
    length = int(input("Enter a password length (or 0 to quit): "))
    if length == 0:
    break
    elif length < 4: # Ensure the length is enough to meet all criteria
    print("Password length must be at least 4 to meet all criteria.")
    else:
    print(f'Generated password: {generatePassword(length)}')

    • @YousefCompSci
      @YousefCompSci  14 ชั่วโมงที่ผ่านมา

      very nice way to add on to the project!