不正なユーザー名とパスワードを入力したときに正しく機能するスクリプトを作成しましたが、正しい資格情報を入力しても返されます失敗しました。動いているものを試しましたが、解決策を見つけることができませんでした。適切な場所に物事がないのですか、いくつかの最終的なコードがありませんか?機能付きログインスクリプト
loggedin = False
wrongcount = 0
def authenticateuser(theusername, thepassword):
theusername = "homerjsimpson"
thepassword = "marge"
def main():
username = ""
password = ""
while loggedin == False and wrongcount < 5:
username = input("Please enter username: ")
password = input("Please enter password: ")
if password == authenticateuser and username == authenticateuser:
loggedin = True
else:
print("Authentication Failed")
wrongcount = wrongcount + 1
loggedin = False
if(loggedin == True):
print("Welcome to the program!")
else:
print("Locked Out")
main()
「authenticateuser) 'function do、そしてこのステートメントは何をするのですか?' password == authenticateuserとusername == authenticateuser: ' – thebjorn
私の非常に初心者の理解から、コードが関数なしで実行された場合、' password == thepasswordとusername == theusername'です。しかし、私は 'authenticateuser'関数を作成したので、私は関数を使用するためにそれらを置き換えました。それがクリアされているかどうかは分かりませんか? –
関数をどこで呼びますか?関数は何を返しますか? – thebjorn