Merhaba arkadaşlar bugün sizinle uzun bir kod paylaşıyorum bende buralarda yeniyim hatalarımı düzeltirseniz güzel olur kaynak ve örnek olması açısından atmak istedim if elif else yapısı bolca bulunmakta iyi günler dilerim.
Python:
#Created by SweeX
#Login System
defKullaniciadi = "enes"
defsifre = "asd"
defeskisifre = "123"
defisim = "henes"
while(True):
dilsecimi = input("Lütfen dilinizi seçiniz(TR veya EN)/Please select language(TR or EN)\nDil/Language:")
if dilsecimi == "TR":
kullaniciadi = input("Kullanıcı adını gir:\n")
sifre = input("Şifrenizi giriniz:")
if defKullaniciadi == kullaniciadi and defsifre ==sifre:
print("Başarıyla giriş yaptınız.")
break
elif (defKullaniciadi != kullaniciadi) and (defsifre == sifre):
systemmessage1 = input("Kullanıcı adını yanlış girdiniz lütfen daha sonra tekrar deneyin.\nKullanıcı adınızı unuttuysanız lütfen 'yardım' yazın:")
if systemmessage1 == "yardım":
defsifre = input("*************************************\n\tHesabınızı kurtarmamız için\n\tlütfen şifreyi girin\n*************************************\n")
if (defsifre == "asd"):
kullaniciisim = input("Lütfen isminizi giriniz:\n\t")
if (kullaniciisim == defisim):
yeniisim = input("Lütfen yeni kullanıcı ismi belirleyiniz:")
yeniisim = defKullaniciadi
else:
print("Hatalı isim girdiniz")
print("Giriş sistemine tekrardan yönlendiriliyor....")
else:
print("Hatalı şifre girdiniz lütfen daha sonra tekrar deneyin")
print("Giriş sistemine tekrardan yönlendiriliyor....")
else:
print("Böyle bir komut bulunamadı.")
print("Giriş sistemine tekrardan yönlendiriliyor....")
elif (defKullaniciadi == kullaniciadi) and (defsifre != sifre):
systemmessage2 = input("Şifreyi yanlış girdiniz lütfen daha sonra tekrar deneyin.\nŞifrenizi unuttuysanız lütfen 'yardım' yazın:")
if systemmessage2 == "yardım":
eskisifre = input("*************************************\n\tHesabınızı kurtarmamız için\n\tlütfen en son hatırladığınız\n\tşifreyi girin\n*************************************\n")
if (eskisifre == defeskisifre or defsifre):
yenisifre = input("Yeni şifre:")
print("Şifreniz",yenisifre,"olarak değiştirildi.")
defeskisifre = defsifre
defsifre = yenisifre
else:
print("Hatalı şifre girdiniz lütfen daha sonra tekrar deneyin")
print("Giriş sistemine tekrardan yönlendiriliyor....")
else:
print("Böyle bir komut bulunamadı.")
print("Giriş sistemine tekrardan yönlendiriliyor....")
elif (defKullaniciadi != kullaniciadi) and (defsifre != sifre):
systemmessage3 = input("Böyle bir kullanıcı bulunamadı Kayıt olmak için 'Kayıt' yazınız")
if systemmessage3 == "Kayıt" or "kayıt":
registerusername = input("Kullanıcı adınızı belirleyin:\n")
registeruserpassword = input("Şifrenizi belirleyin:\n")
defKullaniciadi = registerusername
defsifre = registeruserpassword
print("Başarıyla kayıt oldunuz <3 SweeX")
break
else:
print("Hatalı komut girdiniz.")
print("Giriş sistemine tekrardan yönlendiriliyor....")
elif dilsecimi == "EN":
kullaniciadi = input("Enter your user name:")
sifre = input("Please enter your password:")
if defKullaniciadi == kullaniciadi and defsifre ==sifre:
print("Successfully logged in.")
break
elif (defKullaniciadi != kullaniciadi) and (defsifre == sifre):
systemmessage1 = input("If you entered the username incorrectly, please try again later.if you forgot your user name, please type 'help':")
if systemmessage1 == "help":
defsifre = input("*************************************\n\tPlease enter the password\n\t to recover your account\n*************************************\n")
if (defsifre == "asd"):
kullaniciisim = input("Enter your name:\n\t")
if (kullaniciisim == defisim):
yeniisim = input("Please specify a new user name:")
yeniisim = defKullaniciadi
else:
print("You entered an incorrect name")
print("Rerouting to the Access System....")
else:
print("You have entered an incorrect password please try again later")
print("Rerouting to the Access System....")
else:
print("No such command was found.")
print("Rerouting to the Access System....")
elif (defKullaniciadi == kullaniciadi) and (defsifre != sifre):
systemmessage2 = input("You entered the password incorrectly, please try again later.\n if you forgot your password, please write 'help' :")
if systemmessage2 == "help":
eskisifre = input("*************************************\n\tPlease enter the last password you\n\t remember to recover your account\n*************************************\n")
if (eskisifre == defeskisifre or defsifre):
yenisifre = input("New password:")
print("Your password",yenisifre,"changed to.")
defeskisifre = defsifre
defsifre = yenisifre
else:
print("You have entered an incorrect password please try again later")
print("Rerouting to the Access System....")
else:
print("No such command was found.")
print("Rerouting to the Access System....")
elif (defKullaniciadi != kullaniciadi) and (defsifre != sifre):
systemmessage3 = input("Please type 'Register' to register such a user could not be found")
if systemmessage3 == "Register" or "register":
registerusername = input("Specify your username:\n")
registeruserpassword = input("Set your password:\n")
defKullaniciadi = registerusername
defsifre = registeruserpassword
print("You have successfully registered <3 SweeX")
break
else:
print("You entered an incorrect command.")
print("Rerouting to the Access System....")
else:
print("Böyle bir dil bulunamadı lütfen daha sonra tekrar deneyin" )
print("Giriş sistemine tekrardan yönlendiriliyor....")
print("No such language found please try again later")
print("Rerouting to the Access System....")