علل پرینت نشدن کد خط 9 و 10 چیست
Saeed Kavianypour
7 شهريور ۱۴۰۲
usernames = {'saeed':'123' , 'maryam':'456' , 'shirin':'789'}
add_username = input('user name :')
if add_username in usernames :
print('yes,true')
else:
print('no,false')
add_password = input('password :')
if add_password in usernames :
print('yes,true')
print('well come')
else:
print('no,false')
202
1 پاسخ
- دانیال آذرپناه8 شهريور ۱۴۰۲
سلام و درود. شما اومدین چک کردین که پسورد توی کلید های دیکشنری موجود هست یا نه که باید چک میکردین تو مقدار ها موجود باشه. دقیق نمیدونم چه کدی سعی میکنید بزنید ولی اینیو که من فرستادم چک کنید شاید به جواب رسیدید:
users = {'saeed': '123', 'maryam': '456', 'shirin': '789'} username = input("Enter username: ") if username in users.keys(): print("User is available!") password = input(f"Enter the password for {username}: ") if users[username] == password: print("Congrats! You logged in successfully!") else: print("The password you entered is incorrect!") else: print("We don't have such a user!")
