CodeSolved

A comprehensive source of programming questions and exercises

Login with username and password

Practice Easy 63/ Download 4076 Views

Write a program that receives the user's username and password and checks whether the username and password entered are correct?


Username - Password
Amirhossein - 12345
hooshang - 009922
Manizhe - 00000
MAHSA - M11M3


Example

Username: amirhossein
Password: 12345
OK


Username: amirhossein2
Password: 12345
ERROR

36 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
# Input
E = input("Enter UserName :")
E2= int(input("Enter Password :"))
 
# Oste
if     (E == "Reza" and E2 == 4321) \
    or (E == "Amir" and E2 == 1234) \
    or (E == "Hossein" and E2 == 0000) \
    or (E == "Hessam" and E2 == 1111) :
    print("Movafagh!")
else:
    print("Na Movafagh!")
n=input('enter your name:')
p=input("enter your psword:")

n1=input('enter your name:')
p1=input("enter your psword:")

if n==n1 and p==p1:
    print("hello" + " " + n)
else:
    print("Get lost, stranger")
Omid.asadi Download Python
usernanme = input("enter your username:")
pasword = input("enter your password:")

if usernanme == "amirhossein" and pasword == "12345":
    print(True)
if usernanme == "hooshang" and pasword == "009922":
    print(True)
if usernanme == "manighez" and pasword == "00000":
    print(True)
if usernanme == "mahsa" and pasword == "m11m3":
    print(True)
else:
    print(False)
    
a = ["amirhossein ","hooshang","manizhe","mahsa"]
b=["12345", "009922","00000"," m11m3"]
while 1:
    A=input('User:')
    B=input('Password:')
    try  :
        if A in a and a.index(A)==b.index(B) :
            print ('ok')
        else:
          
           raise exception("error")
        
        break
    except  : 
        print("username ya password eshtebah ast")
User 142 Download Python
a= [" yasna", "yas","vania"," ilia"]
b=["1234", "2345", "4356", "5678"]

A=input("nam karbary:")
B=input("ramz oboor:")

if A in a and  B in b and a.index(A)== b.index(B):
    print(" vared shodid")
else:
    print(" khata")
User 61 Download Python
def check_login(username, password):  
    user_info = {  
        "amirhossein": "12345",  
        "hooshang": "009922",  
        "manizhe": "00000",  
        "mahsa": "m11m3"  
    }  
    return user_info.get(username) == password  
while True:  
    username = input('Enter your username: ')  
    password = input('Enter your password: ')  
    
    if check_login(username, password):  
        print("Login successful!")  
        break 
    else:  
        print("Invalid username or password. Please try again.")
Shinael Download Python
username = input('username: ')
if username == 'manizhe':  
    print('successful')
else:
    print('wrong')
password = int(input('password: '))
if password == 00000:
    print('successful')
else:
    print('wrong')
Akams Download Python
<< Previous page 1 2 4 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close