2017-11-09 16 views
-2

私はPythonの初心者です。私はパスワードプログラムを作ろうとしています。私はあなたのパスワードが正しいものになるまでループするようにプログラムをしたい。Pythonのパスワードプログラムは動作しません。

6行目に何か問題があることがわかります(PassFound == Falseの間)。しかし、私は本当に何が分かりません。あなたにいくつかのアドバイスがありますように。

PassFound = False 
PassWord = input("Create a password") 

print("Okay your password is",PassWord) 

while PassFound == False 
print() 
print() 
print() 
print("You are trying to acces a file without permission") 
print() 
print("Type your password to open this file") 
Typed=input() 

if (Typed == PassWord): 
    print("Password correct") 
    PassFound == True 
    break 


if (Typed != PassWord): 
    print("Password is incorrect, please try again") 
+4

あなたのコードを正しくインデントしてください。 –

+0

'PassFound == False'行にインデントがありません。コロンがありません。 –

答えて

1

コードに複数の問題がありました。 whileループの最後に:がなく、コードのほとんどの領域でインデントが欠けていて、PassFound == True==と同じではないため、動作しませんでした。=と同じではありません。私はあなたがそれを望むことをするためにあなたのコードを編集しましたが、それに関する質問があれば、コメントの中で自由に質問してください。

PassFound = False 
PassWord = input("Create a password") 

print("Okay your password is",PassWord) 

while True: 
    print("\n\n\nYou are trying to acces a file without permission\n") 
    print("Type your password to open this file") 
    Typed=input() 

    if (Typed == PassWord): 
     print("Password correct") 
     break 
    print("Password is incorrect, please try again") 
関連する問題