-2

The code below was working until I add the code under this line:

if questions=="phone not turning on":

After I added the code under that line the code no longer works as intended.

print("Welcome to Bobby Dazler's trobleshooting for mobile phones. Please answer the questions concerning your issue with yes or no, unless specified to write something else. If your issue is none of these listed please enter other or don't know")

solutions1="Place the phone into rice for 24 hours if this does not fix the issue please contact your manufacturer for a repair."
solutions2="Check the battery is in correctly and attempt to charge the phone for atleast one hour, if this fails please contact your manufacturer."
solutions3="Move to a different area, turn the phone on and off, if this fails please contact your service provider."
solutions4="Turn the phone off silent mode, do this by either; manually going into the your phone's settings or use the buttons on the side of the phone to turn it off silent mode."
solutions5="Use the buttons on the side of the phone to adjust the volume accordingly."
solutions6="Contact your manufacturer to arrange a time to fix your cracked phone."
solutions7="Delete some applications(apps) to make some more space for your phone."
solutions8="Contact your manufacturer/insurance company to get your buttons replaced"
solutions9="Charge your phone fully and hold down the button to attempt to turn it on, if this fails please contact your manufacturer to arrange for a repair."
solutions10="Contact your manufacturer to fix your problem"
solutions11="Reinsert the sim card and make sure the sim card is placed the right way upon entering the phone."

print("cracked screen, phone not turning on, bad reception, phone doesn't ring, low volume, can't take photos or download applications, broken/missing buttons, sim card not working, water damage")
questions = input("What problem are you having with your mobile phone? Please select one, please choose on the options and reply in a lower case")


if questions== "cracked screen":  
      print(solutions6)

if questions=="low volume":
    print(solutions5)

if questions=="phone not turning on":
    print(solutions2)
questions = input("Did that fix your issue?")
if questions=="no" or "No":
    print("Okay here's another solution")
    print(solutions9)
questions=input("Did that fix your issue?")
if questions=="no" or "No":
    print("Okay please try this")
    print(solutions10)

if questions=="bad reception":
    print(solutions3)

if questions=="phone doesn't ring":
    print(solutions4)

if questions=="can't take photos or download applications":
    print(solutions7)

if questions=="broken/missing buttons":
    print(solutions8)

if questions=="sim card not working":
    print(solutions11)

if questions=="water damage":
    print(solutions11)

else:

    questions=input("Does the phone turn on?")
    if questions=="Yes" or "yes":
        print("Okay here is another question")

    if questions=="No" or "no":
        print(solutions10)
jwpfox
  • 5,124
  • 11
  • 45
  • 42
  • 1
    Can you provide the error that you're seeing? – alexbclay Sep 18 '16 at 19:08
  • You may wish to read about Python [dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) so you don't have to have the confusing cascade of `if .... then .... else` – dawg Sep 18 '16 at 19:22
  • Possible duplicate of [How do I test one variable against multiple values?](http://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values) – MattDMo Sep 18 '16 at 19:47

1 Answers1

1

Your problem is in this part:

if questions=="Yes" or "yes":
    print("Okay here is another question")

if questions=="No" or "no":
    print(solutions10)

Change if questions=="Yes" or "yes": into one of these:

  • if questions in ("Yes", "yes"):
  • if questions.lower() == "yes":
  • if questions=="Yes" or questions=="yes":

Any of these will work.

x or y means that if one is True, the statement is true. A string is always true as long as it's not empty (Try bool("no") to see). That's why you always enter the part with questions=="Yes" or "yes".

You can also change it into other things which are more suited to this case like:

from distutils.util import strtobool
if strtobool(questions):
    # True, Yes, Y, 1
else:
    # False, No, N, 0
Bharel
  • 23,672
  • 5
  • 40
  • 80