0
我在python 3中創建了一個4位密碼猜測器。我想確保只能輸入4位密碼而不是5或6位密碼。這是我迄今爲止的代碼。限制用戶輸入的數字量
print('your password will not be used or saved for later use you do not have to put in your real password')
real_password = int(input("please enter your four digit phone password here:"))
computer_guess = 0000
guess_counter = 0
yes = 'yes'
no = 'no'
print ("guessing your password...")
while computer_guess < real_password:
computer_guess = computer_guess + 1
guess_counter = guess_counter + 1
print("guess number", guess_counter)
print ("your password is", computer_guess)
'如果real_password> 9999:'?你的問題到底是什麼? – jonrsharpe 2015-02-10 17:07:27