プログラムのコーディングに少し行き詰まっています。バイナリ入力ではないという私の例外は機能していないようです。プログラムを実行すると、「if False in [i == '0' or i == '1' for i in bin2dec]: TypeError: 'int' object is not iterable」というエラー メッセージが表示されます。誰かが助けることができれば。
e1=True
print"Welcome to CJ's Program V1.00.8\n"
while e1:
try:
bininput= int(input("Please enter a binary number: "))
e1=False
except NameError:
print"Please try again.\n"
time.sleep(0.5)
except SyntaxError:
print"Please try again.\n"
time.sleep(0.5)
if False in [i == '0' or i == '1' for i in bininput]:
print "\nIts not Binary number. Please try again."
time.sleep(1)
else:
print "\nIts a Binary number!\n"
decnum = 0
for i in bininput:
decnum = decnum * 2 + int(i)
time.sleep(0.25)
print decnum, "<<This is your answer.\n"