Python Forum
Reaction tester syntax error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reaction tester syntax error
#1
import random



def reactiontest():
print(random.randint(10,99)
start = time.time()
end = time.time()
ReactionTime = end-start
reaction = input("Retype the number here: ")
if reaction == randint:
print("Test successful. It took you" + str(ReactionTime) + "seconds to react.")
else:
print("Your input was incorrect, test failed.")

def main():
print("Press enter when you are ready to take the reaction test."
reactiontest()
print("Do you want to retake the test?")
yesorno = input("Yes or no: ")
if yesorno == "yes":
main()
else: exit


main()
This is some code I have made and I am not sure if it will entirely work because I am new to Python, hopefully you can understand that I am attempting to create a reaction tester through using a random number that the user has to repeat and get correct. Then I want the program to tell the user how long it took them to successfully input the random integer and/or if they entered it correctly or not.

I am getting a syntax error for "start" and I do not know why. This is just a line of code I found online for a counter because I had no idea how to make one and therefore I do not know how to debug it ;/

I appreciate all help regarding the syntax error :)

Thanks ,

-Oli

Now im getting invalid syntax for "reactiontest()"
Moderator Larz60+: I added code tags, please do this yourself (future posts) see BBCODE
Reply
#2
You are missing a close parentheses on the line before start. Always check the line above if you can't figure out an error.

Please read the BBCode link in my signature before you post again.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,255 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 1,968 Oct-30-2020, 05:03 AM
Last Post: deanhystad
  Unspecified syntax error hhydration 1 1,963 Oct-25-2020, 10:45 AM
Last Post: ibreeden
  Annuity function for school - syntax error peterp 2 1,928 Oct-12-2020, 10:34 PM
Last Post: jefsummers
  Invalid syntax error, where? tucktuck9 2 3,378 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Raise an exception for syntax error sbabu 8 3,065 Feb-10-2020, 01:57 AM
Last Post: sbabu
  syntax error: can't assign to operator liam 3 3,994 Jan-25-2020, 03:40 PM
Last Post: jefsummers
  Self taught , (creating a quiz) syntax error on my array DarkAlchemyXEX 9 4,145 Jan-10-2020, 02:30 AM
Last Post: ichabod801
  If Statements and Comparisons returns a syntax error DarkAlchemyXEX 2 2,383 Jan-02-2020, 01:25 PM
Last Post: DarkAlchemyXEX
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,027 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