CodeSolved

Solved Programming Questions & Exercises

Login with username and password

Practice Easy 63/ Download 5833 Views Most popular

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

50 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.
# Receives from the user
user = input("username :")
password = input("password :")

# Examine the information received with existing information and printing the output
if user == "amirhossien" and password == "12345":
    print("ok")
elif user == "hooshang" and password == "009922":
    print("ok")
elif user == "manizhe" and password == "00000":
    print("ok")
elif user == "mahsa" and password == "m11m3":
    print("ok")
else:
    print("error...")

What do you think about? Hossien.abbasi


def check_credentials(username, password):
    # Dictionary to maintain valid usernames and passwords
    valid_credentials = {
        'amirhossein': '12345',
        'hooshang': '009922',
        'manizhe': '00000',
        'mahsa': 'm11m3'
    }
    
    # Check the accuracy of the username and password
    if username in valid_credentials and valid_credentials[username] == password:
        return "ok"
    else:
        return "error"

def main():
    username = input("نام کاربری را وارد کنید: ")
    password = input("رمز عبور را وارد کنید: ")
    
    result = check_credentials(username, password)
    print(result)

if __name__ == "__main__":
    main()
User 136 Download Python
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
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 5 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close