In this Blog:

We will Learn about:

Random & String Module

Using of Lists with if statement.

Random Module:

Python Random module is an in-built module of Python which is used to generate random numbers. These are pseudo-random numbers means these are not truly random. This module can be used to perform random actions such as generating random numbers, print random a value for a list or string.

String Module:

The string Module contain number of function to Process standard Python string.

List in Python:

List in Python are the built-in Data Types used to store the multiple item in a single variable and also to store collection of data.

CODE:

Who can Login:

Only selective Name can  login  enter in the list.

CODE in Text Formate:

"""Login account by generating Random password """
import random 
import string
l=['Ahmad','AI']
def pass_gen():
      
 #Length of password 
 print("To generate the password \n ")
 length=int(input("Enter the length of the password : "))
 # Defining the data we use in the password 
 # we can also separatly do it by assigning variables:
 all = string.ascii_letters + string.digits
 passw = "".join(random.sample(all,length))
 
 print(passw)

passg=pass_gen()
user_name=input("Enter your name:\n ") 
if user_name in l:
    print( " To login your account :")
    login=input("Enter your generted password:\n ")
    login=passg
    if login==passg:
        print("Your account is Login !")
        print(f"Welcome sir {user_name}")
else:
    print(" Your user name is in correct!")

THANKS FOR READING !----