I have currently made a python program that is supposed to take a users input, find the keyword and find a text to go with it. One problem: It doesn't work. Code will be below:
import time
import sys
e=0
brokenscreen= "crack cracked smashed".split()
newtest= "turning turn".split()
buttons= "buttons button".split()
sound= "sound speaker volume".split()
frozen= "frozen unresponsive responding".split()
WiFi= "wi-fi wifi disconnecting wifi".split()
memory= "memory data".split()
removeapps= "uninstall removeapps appremove uninstal apps app".split()
wipe= "completerestart restart wipe".split()
water= "water wet".split()
camera= "camera cam".split()
bad= "bad rubbish terrible".split()
black= "black calls".split()
notifications= "notifications"
anlist=[brokenscreen, newtest, buttons, sound, frozen, WiFi, memory, removeapps, wipe, water, camera, bad, black, notifications]
anPrint=[
"You need to repair it in a store.",
"Check that it has full charge, or check it is definately charging. You will need to take it to the store to get it checked.",
"Button Savior will bring your phone hardware keys to your home screen. After you install and run the app, you will see a small pull out arrow on the right edge of the screen.\n Tap on it and yu should have buttons on screen.",
"If your phone suffer from low volume then you can download AudioBoost from the market. It can increase the volume up to 30% and is also activated from home screen widget.",
"You just need to restart your phone to kickstart a frozen phone.",
"This may solve the problem. Just go to Wi-Fi > Settings > Menu > Advanced and choose to stay connected to Wi-Fi during sleep.",
"Among other reasons, the most prominent problem can be a full cache which affects the efficient running of apps. You can download apps like Cache Cleaner or Clean Master from Google Play",
"Go to Settings > Applications > Manage Applications and then select the app you wish to uninstall. Now tap the Uninstall icon to remove the app.",
"Go to Settings > SD & Phone storage > Factory Data Restore. Go through the process twice to be completely sure that everything has been removed.",
"Take the battery out as quickly as possible and dry as many parts of the phone as you can then leave it for 72 hours in a dry room. \n Try it again, it may work. Also try putting the phone and components into a bowl of rice.",
"If the camera doesn't work, let the camera take the photo at the default resolution, then scale it to your preferred size in an AsyncTask, an app on the app store.",
"I'd reccomend android. Anything but apple. Get a new phone.",
"Some people have reported success by pushing on the screen where the proximity sensor is located, which suggests a build issue. There is no fix for this issue yet.",
"Check your Wi-Fi or data connection. Poor coverage will impact on push notifications. Go to Settings > Wi-Fi > Advanced and tick the box next to Keep WiFi on when screen times out."
]
def restart():
yes_no=input("Restart? (Y/n): ").lower()
if yes_no:
return yes_no[0] == 'y'
return True
def program(pos):
if z=="an" or z=="and" or z=="android":
for word in a:
item=anlist[pos]
if word in item:
print(anPrint[pos])
time.sleep(0.5)
pos=pos+1
elif word not in anlist:
pos=pos+1
sys.exit
return pos
while True:
z=input("ANDROID™ TROUBLESHOOTING (Alpha Testing 0.9.5) Enter the word 'Android': ")
if z=="and" or z=="an" or z=="android":
a=input("Describe your problem please: ").lower().split()
program(e)
restart()
else:
print("No valid input detected.")
restart()
if not restart():
break
It works perfectly well when I use something like 1 keyword, it finds the sentence to go with it and executes almost perfectly, but I have problems when I try to restart (Labeled with "repeat question") and actually printing out the statement when the user writes a sentence. Any help is appreciated thanks guys
EDIT: Fixed restart
whileloop around your first function definition, and an IndentationError around your firstelif. It doesn't even run on my machine.for word in anlist: for word in a:thewordinaoverrides thewordinanlist, so any reference towordreferencesa... which as far as I can tell is undefined at that point.while True: def restart(): ...block? Doesn't that just define therestartfunction an infinite number of times? O.o