Python Forum
Self taught , (creating a quiz) syntax error on my array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Self taught , (creating a quiz) syntax error on my array
#1
Im self teaching python , trying to create a quiz but Im having a error on line 17 , im importing from from this code
Quote:Question.py
class Question:
	def__init__(self, prompt, answer):
		self.prompt = prompt
		self.answer = answer
for file
Quote:building a multiple choice quiz.py
from Question import Question

question_promts = [
	"What color are apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n",
	"What color are Bananas?\n(a) Teal\n(b) Magenta\n(c) Yellow\n\n" ,
	"What color are strawberries?\n(a) Yellow\n(b) Red\n(c) Blue\n\n"
]

questions = [
	Question(question_prompts[0],"a" ),
	Question(question_prompts[1],"c" ),
	Question(question_prompts[2],"b" ),
]

def run_test(questions):
	score = 0
	for question in questions
		answer = input(question.prompt)
		if answer == question.answer:
			score += 1
	print("You got " + str(score) + "/" + str(len(questions)) + "correct")
	
	run_test(questions)
However it keeps telling me that I have a syntax error on line 17 when I run the program.
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pyroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile.mainpyfile)
File "/data/user/0/ru.iiec.pyroid2/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read().   __main__.__dict__)
File "<string>", line 17
for question in questions
                        ^
SyntaxError: invalid syntax

[Program finished]
Reply


Messages In This Thread
Self taught , (creating a quiz) syntax error on my array - by DarkAlchemyXEX - Jan-09-2020, 04:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,402 Aug-11-2022, 08:43 PM
Last Post: deanhystad
  I'm getting a syntax error very early on in my code and I can't quite figure it out. liloliveoil 1 2,043 Oct-30-2020, 05:03 AM
Last Post: deanhystad
  Unspecified syntax error hhydration 1 2,054 Oct-25-2020, 10:45 AM
Last Post: ibreeden
  Annuity function for school - syntax error peterp 2 2,037 Oct-12-2020, 10:34 PM
Last Post: jefsummers
  Invalid syntax error, where? tucktuck9 2 3,460 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Raise an exception for syntax error sbabu 8 3,286 Feb-10-2020, 01:57 AM
Last Post: sbabu
  syntax error: can't assign to operator liam 3 4,102 Jan-25-2020, 03:40 PM
Last Post: jefsummers
  If Statements and Comparisons returns a syntax error DarkAlchemyXEX 2 2,493 Jan-02-2020, 01:25 PM
Last Post: DarkAlchemyXEX
  creating functions which modify numpy array GSGSGKGK 0 1,613 Dec-15-2019, 07:04 PM
Last Post: GSGSGKGK
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,129 Oct-19-2019, 01:40 AM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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