Today I was writing this program
from random import randint
def practice():
command = input("Welcome to math practice! Type mult tables to practice multiplication tables, or simp add for single digit addition")
if command == "mult tables":
while True:
first_value_x = randint(2, 12)
second_value_x = randint(2, 12)
number_x = int(input("%s x %s" % (first_value_x, second_value_x )))
if number_x == first_value_x * second_value_x:
print("Correct!!")
else:
print("You did not get the answer correct.")
elif command == "simp add":
while True:
first_value_simp_add = randint(1,9)
second_value_simp_add = randint(1,9)
number_simple_add = int(input("What is %s + %s" %(first_value_simp_add, second_value_simp_add)))
if number_simple_add == first_value_simp_add + second_value_simp_add:
print("Well done!")
else:
print("You did not the answer correct")
else:
print("The command you entered does not exist. Please retype a command")
practice()
practice()
However, I keep getting this error
SyntaxError: unexpected EOF while parsing
or more specifically
Traceback (most recent call last):
File "/Users/student/Desktop/math practice.py", line 49, in <module>
practice()
File "/Users/student/Desktop/math practice.py", line 6, in practice
command = input("Welcome to math practice! Type mult tables to practice multiplication tables, or simp add for single digit addition")
File "<string>", line 1
simp add
^
SyntaxError: unexpected EOF while parsing
or
Traceback (most recent call last):
File "/Users/student/Desktop/math practice.py", line 49, in <module>
practice()
File "/Users/student/Desktop/math practice.py", line 6, in practice
command = input("Welcome to math practice! Type mult tables to practice multiplication tables, or simp add for single digit addition")
File "<string>", line 1
mult tables
^
SyntaxError: unexpected EOF while parsing
When I try to enter the mult tables
or simp add
commands in the input.
I have relooked over my code many times and read a bunch of other SyntaxError: unexpected EOF while parsing
threads, yet still cannot find where I went wrong. Sorry if its obvious I'm very new to this kind of stuff. Please help!