I'm in the process of teaching myself to code and am currently working on a dice roller as a learning project. I'm runnng into a bit of an odd snag at the moment the moment. The fourth 'def' in my code, no matter what it actually is (I've tried with several that all work individually) it keeps getting flagged as a syntax error. Here's what I have:
import random
def mult():
print('How many dice would you like to roll?')
multiplier = input()
mod()
def mod():
print('What modifier, if any, would you like to assign?')
modifier = input()
result()
def result():
total = (roll * multiplier) + modifier
print('Your result is'
(str(total)
def menuscreen():
print("Welcome to Jack's dice roller. What kind of die would you like to roll?")
print("")
print("A. d2")
print("B. d4")
print("C. d6")
print("D. d8")
print("E. d10")
print("F. d12")
print("G. d20")
print("H. d100")
def gen():
menuscreen()
if input() == 'a' or 'A':
roll = random.randint(1,2)
mult()
if input() == 'b' or 'B':
roll = random.randint(1,4)
mult()
if input() == 'c' or 'C':
roll = random.randint(1,6)
mult()
if input() == 'd' or 'D':
roll = random.randint(1,8)
mult()
if input() == 'e' or 'E':
roll = random.randint(1,10)
mult()
if input() == 'f' or 'F':
roll = random.randint(1,12)
mult()
if input() == 'g' or 'G':
roll = random.randint(1,20)
mult()
if input() == 'h' or 'H':
roll = random.randint(1,100)
mult()
def queryque():
print('Would you care to roll again?')
if input == 'yes':
gen()
if input == 'no':
end
gen()
SyntaxErroron a line that looks perfectly valid, look upward to see if you missing a)(or, occasionally, a]or}). That's a very common error—the missing)means it's trying to interpret the next line as part of the expression in the previous line, and you can't throw, say, adefin the middle of an expression. You may also want to consider getting a better editor that can assist you with balancing parens; they're useful for almost all programming languages.