Python Forum
Pointer in the right direction?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pointer in the right direction?
#3
Thanks! I am going to figure out the tagging part better. I have played around making multiple choices and some other ideas as well. I will add more questions later, now it is more about learning.

What I am trying to solve is that for each question in the quiz I have to copy/paste the code manually again. My thinking was that there must be a way to automate that.

First time: questionList[0]

Second time: questionList[1]

and so forth...

But perhaps it is a non-issue! :)

This is what it looks like at the moment:

class Question:
  def __init__(self, question, answer):
    self.question = question
    self.answer = answer

questionList = []
questionList.append(Question("What is the capital of Colombia", "Bogota"))
questionList.append(Question("What is the capital of Chile?", "Santiago"))

print(questionList[0].question)

for i in range(3):
    answer = input("Response: ")
    if answer == (questionList[0].answer):
        print("Correct answer")
        break
    if answer != questionList[0].answer:
        continue
else:
    print("Wrong Answer")
    print()
    print("The correct answer was:", questionList[0].answer)

print(questionList[1].question)

for i in range(3):
    answer = input("Response: ")
    if answer == (questionList[1].answer):
        print("Correct answer")
        break
    if answer != questionList[1].answer:
        continue
else:
    print("Wrong Answer")
    print()
    print("The correct answer was:", questionList[1].answer)
Reply


Messages In This Thread
Pointer in the right direction? - by Viking - Apr-21-2020, 07:57 PM
RE: Pointer in the right direction? - by deanhystad - Apr-21-2020, 08:00 PM
RE: Pointer in the right direction? - by Viking - Apr-21-2020, 08:24 PM
RE: Pointer in the right direction? - by deanhystad - Apr-21-2020, 08:47 PM
RE: Pointer in the right direction? - by snippsat - Apr-22-2020, 01:14 AM
RE: Pointer in the right direction? - by Viking - Apr-22-2020, 06:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Project Direction bclanton50 1 1,382 Jan-06-2022, 11:38 PM
Last Post: lucasbazan
Question How to understand the vector/direction mason321 0 1,165 Dec-14-2021, 10:57 PM
Last Post: mason321
  General pointer to start data4speed 3 2,049 Jul-01-2020, 06:18 AM
Last Post: DPaul
  Length and direction cosines of lines tarikrr 1 1,816 Nov-15-2019, 04:16 AM
Last Post: SheeppOSU
  Some direction needed Patriot1017 3 2,567 Sep-03-2019, 05:44 PM
Last Post: jefsummers
  Practicing using a "flag": please point in right direction magsloo 5 3,219 May-10-2019, 04:58 AM
Last Post: perfringo
  VM address (C pointer) of Python object Skaperen 1 2,104 Apr-21-2019, 10:57 PM
Last Post: hshivaraj
  trace invalid pointer simon149 7 5,289 Apr-16-2019, 07:05 AM
Last Post: simon149
  How to create a graph for direction visualization Visiting 2 2,844 Sep-22-2018, 10:49 PM
Last Post: Visiting
  Need tutorial/direction to access shared memory ridshack 2 3,084 Feb-22-2018, 11:24 PM
Last Post: ridshack

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020