Python Forum

Full Version: Reaction tester syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.