0
from array import *
from math import *
from string import *
from random import *
from time import *
arrayQueryCategories = [["cracked","screen","display","smashed","broken","dropped"],#BrokenScreen
["wet","damp","moist","water","soaked","liquid"],#WetPhone
["charging","power","battery","plug","won't"],#NotCharging
["turn","on","off","activate","black"],#WontTurnOn
["buttons","stuck","press","home","lock","volume","mute"],#ButtonsBroken
["locked","out","time","wait","code","password","stuck","unlock","passcode"]]#LockedOut
def defSearchFor():
global Result
Result = []
Query = input("Search Term: ")
Query = Query.lower()
Counter = 0
while Counter < len(arrayQueryCategories):
print(str(Counter))
try:
Result.append(arrayQueryCategories[Counter].index(Query))
print("good")
except ValueError:
print("bad")
Result.append(-1)
Counter = Counter + 1
print(str(Result))
defRespondTo()
def defRespondTo():
Responses = ["PlaceHolder-BrokenScreen","PlaceHolder-WetPhone"\
"PlaceHolder-NotCharging","PlaceHolder-WontTurnOn"\
"PlaceHolder-ButtonsBroken","PlaceHolder-Lockedout"]
Counter = 0
while Counter <= len(arrayQueryCategories):
if Result[Counter] != -1:
print(Responses[Counter])
Counter = Counter + 1
defSearchFor()
defSearchFor()
結果:
Search Term: broken
0
good
1
bad
2
bad
3
bad
4
bad
5
bad
[4, -1, -1, -1, -1, -1]
PlaceHolder-BrokenScreen
Search Term: lock
0
bad
1
bad
2
bad
3
bad
4
good
5
bad
[-1, -1, -1, -1, 4, -1]
有代碼和結果。在此之後,結果只是停止輸出,但沒有「>>>」表示過程已完成。爲什麼不重新發布?代碼應該無限循環。我的代碼有什麼問題?
謝謝!這使我的任務變得更加簡單,謝謝! – SeanOTRS
如果這有用,請考慮upvoting和接受。 –