adding a counter to a quiz [on hold]












-2














i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help



from random import randint

path = ("/home/pi/Desktop/")
filename = ("CapitalCities.txt")
file = open(path + filename,"r")
counter = 0
incounter = 0
Lines = 0
for line in file:
Lines+=1
file.close()
file = open(path + filename,"r")

def wordcheck(cap,q_answer):
T = 0
for word in cap:
if word !=q_answer[T]:
print(word)

def generateQuiz():
incounter = 0

counter = 0
file = open(path + filename,"r")
randomquestion = randint(0,Lines)
count = 0
line = 0

for line in file:
count+=1
if(randomquestion == count):
question = line
sep = question.find("-")
cnt = question [:sep]
cap = question[sep+1:]
cap = cap.strip()
print ("Capital :"+ cap)
q_answer = input("what is the capital of "+ cnt +"?: ")
if q_answer != cap:
print(("Wrong! the answer is ")+ cap)
incounter += 1
return
else:
print("Well Done")
counter += 1
return
elif not line:



for i in range(3):
generateQuiz()
incounter_str = str(incounter)
counter_str = str(counter)
print(counter_str+" correct "+ incounter_str+ "incorrect")









share|improve this question







New contributor




Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by AJNeufeld, Jamal yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.


















    -2














    i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help



    from random import randint

    path = ("/home/pi/Desktop/")
    filename = ("CapitalCities.txt")
    file = open(path + filename,"r")
    counter = 0
    incounter = 0
    Lines = 0
    for line in file:
    Lines+=1
    file.close()
    file = open(path + filename,"r")

    def wordcheck(cap,q_answer):
    T = 0
    for word in cap:
    if word !=q_answer[T]:
    print(word)

    def generateQuiz():
    incounter = 0

    counter = 0
    file = open(path + filename,"r")
    randomquestion = randint(0,Lines)
    count = 0
    line = 0

    for line in file:
    count+=1
    if(randomquestion == count):
    question = line
    sep = question.find("-")
    cnt = question [:sep]
    cap = question[sep+1:]
    cap = cap.strip()
    print ("Capital :"+ cap)
    q_answer = input("what is the capital of "+ cnt +"?: ")
    if q_answer != cap:
    print(("Wrong! the answer is ")+ cap)
    incounter += 1
    return
    else:
    print("Well Done")
    counter += 1
    return
    elif not line:



    for i in range(3):
    generateQuiz()
    incounter_str = str(incounter)
    counter_str = str(counter)
    print(counter_str+" correct "+ incounter_str+ "incorrect")









    share|improve this question







    New contributor




    Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.











    put on hold as off-topic by AJNeufeld, Jamal yesterday


    This question appears to be off-topic. The users who voted to close gave this specific reason:


    • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal

    If this question can be reworded to fit the rules in the help center, please edit the question.
















      -2












      -2








      -2







      i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help



      from random import randint

      path = ("/home/pi/Desktop/")
      filename = ("CapitalCities.txt")
      file = open(path + filename,"r")
      counter = 0
      incounter = 0
      Lines = 0
      for line in file:
      Lines+=1
      file.close()
      file = open(path + filename,"r")

      def wordcheck(cap,q_answer):
      T = 0
      for word in cap:
      if word !=q_answer[T]:
      print(word)

      def generateQuiz():
      incounter = 0

      counter = 0
      file = open(path + filename,"r")
      randomquestion = randint(0,Lines)
      count = 0
      line = 0

      for line in file:
      count+=1
      if(randomquestion == count):
      question = line
      sep = question.find("-")
      cnt = question [:sep]
      cap = question[sep+1:]
      cap = cap.strip()
      print ("Capital :"+ cap)
      q_answer = input("what is the capital of "+ cnt +"?: ")
      if q_answer != cap:
      print(("Wrong! the answer is ")+ cap)
      incounter += 1
      return
      else:
      print("Well Done")
      counter += 1
      return
      elif not line:



      for i in range(3):
      generateQuiz()
      incounter_str = str(incounter)
      counter_str = str(counter)
      print(counter_str+" correct "+ incounter_str+ "incorrect")









      share|improve this question







      New contributor




      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help



      from random import randint

      path = ("/home/pi/Desktop/")
      filename = ("CapitalCities.txt")
      file = open(path + filename,"r")
      counter = 0
      incounter = 0
      Lines = 0
      for line in file:
      Lines+=1
      file.close()
      file = open(path + filename,"r")

      def wordcheck(cap,q_answer):
      T = 0
      for word in cap:
      if word !=q_answer[T]:
      print(word)

      def generateQuiz():
      incounter = 0

      counter = 0
      file = open(path + filename,"r")
      randomquestion = randint(0,Lines)
      count = 0
      line = 0

      for line in file:
      count+=1
      if(randomquestion == count):
      question = line
      sep = question.find("-")
      cnt = question [:sep]
      cap = question[sep+1:]
      cap = cap.strip()
      print ("Capital :"+ cap)
      q_answer = input("what is the capital of "+ cnt +"?: ")
      if q_answer != cap:
      print(("Wrong! the answer is ")+ cap)
      incounter += 1
      return
      else:
      print("Well Done")
      counter += 1
      return
      elif not line:



      for i in range(3):
      generateQuiz()
      incounter_str = str(incounter)
      counter_str = str(counter)
      print(counter_str+" correct "+ incounter_str+ "incorrect")






      python-3.x quiz






      share|improve this question







      New contributor




      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      Louie bernard LaybatsLouie bernard Laybats

      1




      1




      New contributor




      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Louie bernard Laybats is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      put on hold as off-topic by AJNeufeld, Jamal yesterday


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal

      If this question can be reworded to fit the rules in the help center, please edit the question.




      put on hold as off-topic by AJNeufeld, Jamal yesterday


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal

      If this question can be reworded to fit the rules in the help center, please edit the question.






















          0






          active

          oldest

          votes

















          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

          is 'sed' thread safe

          How to make a Squid Proxy server?