这是我的代码,每当它运行时它跳过一个代码块,它不显示任何错误或任何东西它只是跳过我的第一个if条件并运行其余的,这里它是=
import time
#Cracking PINs
pin = str(input('Type in your 6-digit PIN, it MUST be a number: \n'))
pinLength = len(pin)
solvePin = 0.000002
easyPins = [000000, 0.123456, 0.11111, 0.222222, 0.333333, 0.444444, 0.555555, 0.666666, 0.777777, 0.888888, 0.999999, 0.456123]
pin = int(pin)
pin = pin/1000000
#PIN strength
while(pin in easyPins):
print('Your PIN is too weak, make another one')
pin = int(input())
print('Strong PIN!')
#Checking PIN Length and Cracking PIN
startTime = time.time()
if(pinLength == 8):
confirmPin = int(input('Confirm your PIN \n'))
confirmPin = confirmPin/1000000
while(confirmPin != pin):
print('Not the same PIN\n')
confirmPin = int(input('Please retype your PIN\n'))
while(solvePin != confirmPin):
solvePin += 0.000001
print(solvePin)
else:
while (pinLength != 8):
int(input('Your PIN is too long or short, type again.\n'))
print(' ')
print('Your Pin is')
print(solvePin)
endTime = time.time()
print(' ')
print ('Elapsed time in seconds', ((endTime - startTime)))
你有一行
if(pinLength == 8)
但是你提示人们输入一个6位的pin。所以if
永远不是真的。你知道吗此外,下面的
else
块没有正确缩进。它没有与if(pinLength == 8)
对齐,因此else
也不会被调用。你知道吗因为这是在
else
中,即使您修复了缩进以便调用它,一旦调用-您的脚本将一直运行到最后,永远不会经过验证while
循环。你知道吗实际上我会推荐这样的东西。。。
输出:
相关问题 更多 >
编程相关推荐