這是一個程序,需要3位數字,存儲它們,並重復猜測和檢查,直到三個存儲的數字匹配3個猜測的數字。我似乎無法得到任何東西超過第一個while循環執行:爲什麼不執行此代碼?
digitone = int(raw_input())
digittwo = int(raw_input())
digitthree = int(raw_input())
digitthree = int(raw_input())
countdigitone = 0
countdigittwo = 0
countdigitthree = 0
while digitone <= countdigitone:
if digitone < countdigitone:
print "Digit one could be", countdigitone
countdigitone += 1
elif digitone == countdigitone:
print "Digit one is", countdigitone
while digittwo <= countdigittwo:
if digittwo < countdigittwo:
print "The first two digits could be", countdigitone, countdigittwo
countdigittwo += 1
elif digittwo == countdigittwo:
print "Digits one and two are", countdigitone, countdigittwo
while digitthree <= countdigitthree:
if digitthree < countdigitthree:
print "The 3-digit number could be", countdigitone, countdigittwo, countdigitthree
countdigitthree += 1
elif digitthree == countdigitthree:
print "This is most definetly the number!", countdigitone, countdigittwo, countdigitthree
break
它就在那裏。目前,它只需要你的號碼,打印單詞無,然後停下來。有沒有什麼辦法解決這一問題?
您輸入的數字是否爲'digitone' <= 0?如果不是,那麼while循環不會執行。 – 2014-11-03 20:21:36
你爲什麼要嵌套三個while循環?你爲什麼要問'digitthree'的價值兩次? – 2014-11-03 20:26:11
@jgritty我看到我做了什麼。現在的問題是,這裏'countdigitone + = 1'我試圖增加'countdigitone'的數量。 – 2014-11-03 20:26:54