Python NameError: name '' is not defined
<p>I am fairly new to python, i have created this code for a controlled assessment but it is suggesting that 'q11' (the first of the web opening commands) is not defined. It is the same as the others and was working fine before but now i have begun work on it again but it just won't work. </p>

<p>Thank you in advance </p>

<p>Here is my code:</p>

<pre><code>import webbrowser
import random
sol1 = ("Check if there is lint in the charging ports. This can be removed            carefully with a toothpick or similar implement")
sol2 = ("Turn on assistive touch if you have an iphone (settings &gt; general &gt;    accessability &gt; assistive touch until you go to a shop to get them replaced. If  you use android, download 'button savior' from the google play store")
sol3 = ("Do a hard reset - hold down the power and home buttons until the screen  turns off and keep them held down until the screen turns on again ")
sol4 = ("Restore the phone to factory settings and set it up as new")
sol5 = ("You need a screen replacement.")
sol6 = ("You may need to replace the battery.")
sol7 = ("You dont need to do anything. Your phone doesnt have any problems.")
sol8 = ("Please update your phone software.")
sol9 = ("Contact apple for support")
sol10 = ("Take the phone and put it in a bag of rice for  24-36 hours to let the rice absorb the water.")


q1=input("Is your phone charging correctly? ")
 if q1 == "no":
    print(sol1)
if q1 == "yes":

q2=input("Is your phone water damaged? ")
  if q2 == "yes":
      print(sol10)
if q2 == "no":

q3=input("Is the screen cracked or badly scratched? ")
 if q3 == "yes":
     print(sol5)
if q3 == "no":

q4=input("Is the phone working slowly and crashing? ")
 if q4 == "yes":
     print(sol3)
if q4 == "no":

q5=input("Do you wish to remove data from the phone? ")
 if q5 == "yes":
     print(sol4)
if q5 == "no":

q6=input("Does the phone work without issues? ")
 if q6 == "yes":
     print(sol7)
if q6 == "no":

q7=input("Are you running the lastest software version? ")
  if q7 == "no":
     print(sol8)
if q7 == "yes":

q8=input("Are the buttons producing accurate responses ")
 if q8 == "no":
     print(sol2)
if q8 == "yes":

q9=input("Is your phone battery draining and dying early? ")
 if q9 == "yes":
    print(sol6)
if q9 == "no":

q10=input("Does the phone turn on, even if it has been charged with a working charger? ")
 if q10 == "yes":
     print(sol9)
if q10 == "no":

q11=input("Would you like to visit the apple support site?: yes/no ")
 if q11 == "yes":
      webbrowser.open("https://support.apple.com/en-gb")
if q11 == "no":

q12=input("Would you like to visit the genius bar booking site?: yes/no ")
 if q12 == "yes":
      webbrowser.open("https://getsupport.apple.com/")
 if q12 == "no":
</code></pre>

<p>print("Thank you for using this service. We hope you found it useful")</p>

<p>Alternatively you could just make it so they input either y or n which would be a lot less lines of code.</p>

<p>All I did differently from my previous answer is simply only made it loop once to change the 'Y' to lowercase or 'N' to lowercase. It's better to make it like this because when people use a program and are asked to input 'Y' they sometimes do 'y' instead, so always best to be sure.</p>

<p>Also adding elif instead of if for a second if statement on the same thing is neater programming, somehow python allows it but if you ever move on to another programing language you have to use elif so may aswell get used to it now.</p>

<pre><code>sol1 = ("Check if there is lint in the charging ports. This can be removed            carefully with a toothpick or similar implement")
</code></pre>

<p>Another tip this variable above could be made into something a lot better than a spam of spaces, did you know '\n' in a string starts a new line. </p>

<pre><code>import webbrowser
import random
sol1 = ("Check if there is lint in the charging ports. This can be removed\ncarefully with a toothpick or similar implement")
sol2 = ("Turn on assistive touch if you have an iphone (settings &gt; general &gt;\naccessability &gt; assistive touch until you go to a shop to get them replaced If  you use android, download 'button savior' from the google play store")
sol3 = ("Do a hard reset - hold down the power and home buttons until the screen\nturns off and keep them held down until the screen turns on again ")
sol4 = ("Restore the phone to factory settings and set it up as new")
sol5 = ("You need a screen replacement.")
sol6 = ("You may need to replace the battery.")
sol7 = ("You dont need to do anything. Your phone doesnt have any problems.")
sol8 = ("Please update your phone software.")
sol9 = ("Contact apple for support")
sol10 = ("Take the phone and put it in a bag of rice for\n24-36 hours to let the rice absorb the water.")

q1 = str(input("Is your phone charging correctly? Y/N &gt;&gt; "))
for i in range(1):
    q1 = str.lower(q1)
if q1 == "n":
    print(sol1)

elif q1 == "y":
    q2 = str(input("Is your phone water damaged? Y/N &gt;&gt; "))
    for i in range(1):
        q2 = str.lower(q2)
if q2 == "y":
    print(sol10)

elif q2 == "n":
    q3 = str(input("Is the screen cracked or badly scratched? Y/N &gt;&gt; "))
    for i in range(1):
        q3 = str.lower(q3)
if q3 == "y":
    print(sol5)

elif q3 == "n":
    q4 = str(input("Is the phone working slowly and crashing? Y/N &gt;&gt; "))
    for i in range(1):
        q4 = str.lower(q4)
if q4 == "y":
    print(sol3)

elif q4 == "n":
    q5 = str(input("Do you wish to remove data from the phone? Y/N &gt;&gt; "))
    for i in range(1):
         q5 = str.lower(q5)
if q5 == "y":
    print(sol4)

elif q5 == "n":
    q6 = str(input("Does the phone work without issues? Y/N &gt;&gt; "))
    for i in range(1):
        q6 = str.lower(q6)
if q6 == "y":
    print(sol7)

elif q6 == "n":
    q7 = str(input("Are you running the lastest software version? Y/N &gt;&gt; "))
    for i in range(1):
        q7 = str.lower(q7)
if q7 == "n":
    print(sol8)

elif q7 == "y":
    q8 = str(input("Are the buttons producing accurate responses Y/N &gt;&gt; "))
    for i in range(1):
        q8 = str.lower(q8)
if q8 == "n":
     print(sol2)

elif q8 == "y":
    q9 = str(input("Is your phone battery draining and dying early? Y/N &gt;&gt; "))
    for i in range(1):
        q9 = str.lower(q9)
if q9 == "y":
    print(sol6)

elif q9 == "n":
    q10 = str(input("Does the phone turn on, even if it has been charged with a working charger? Y/N &gt;&gt; "))
    for i in range(1):
        q10 = str.lower(q10)
if q10 == "y":
     print(sol9)

elif q10 == "n":
    q11 = str(input("Would you like to visit the apple support site?: yes/no Y/N &gt;&gt; "))
    for i in range(1):
        q11 = str.lower(q11)
if q11 == "y":
    webbrowser.open("https://support.apple.com/en-gb")

elif q11 == "n":
    q12 = str(input("Would you like to visit the genius bar booking site?:  Y/N &gt;&gt; "))
    for i in range(1):
        q12 = str.lower(q12)

if q12 == "y":
    webbrowser.open("https://getsupport.apple.com/")
else:
    print()
</code></pre>

python undefined defined