2016-11-13 2 views
-1

オーケー右の時間を印刷していないが、ここでは、コードPythonのforループ2.7と私はシンプルなログインシステムを書いていますので

import time 
for counter in range(5): 
    username=str(raw_input("Please enter your username")) 
    password=str(raw_input("Please enter your password")) 
    if username =="bros10": 
    print "",username,"entered" 
    time.sleep(4) 
    print "You got the username right" 
    if password =="brosbros10": 
     print "You got the password right" 
     print "Welcome to the system" 
     break 

else: 
    print "Try again" 

であり、私はそれはそれは、このビットプリント」を印刷することで実行したときに何が起こりますパスワードを入力した後でユーザ名 "入力済み" 助けを歓迎します

+0

私は理解できません。パスワードの前に印刷して後で印刷したいですか?もしそうなら、コードはあなたが求めていることをしています。 'password'の入力を行う前に' print'を移動してみてください。 – Aurora0001

+0

あなたはあなたが期待していることを言っていませんでした。あなたの問題は何ですか ? – furas

答えて

0

あなたが正しいことを理解すれば、パスワードを入力する前にprint "",username,"entered"にします。そして、それは次のようになります。

import time 
for counter in range(5): 
    username=str(raw_input("Please enter your username")) 
    print "",username,"entered" 
    if username == "bros10": 
    print "You got the username right" 
    password=str(raw_input("Please enter your password")) 
    time.sleep(4) 
    if password =="brosbros10": 
     print "You got the password right" 
     print "Welcome to the system" 
     break 

    print "Try again" 
1

移動この:この前に

print "",username,"entered" 

password=str(raw_input("Please enter your password")) 

今入力したユーザー名を繰り返して、ユーザ名を要求しますあなたのプログラム(ユーザにbros10と入力した場合は正しいと伝えます)、パスワードを尋ねてから4秒間スリープします。あなたはそれが4秒を待っていると、ユーザーの入力を繰り返した後、パスワードを要求する場合

また、あなたはこの1

if password =="brosbros10": 

password=ラインを右に配置することができます。

関連する問題