Elif error occured while the python programming -
# input values. b1 = input('please enter base.') i1 = input('please enter index.') # define funciton parameter 'base' , 'index'. def square(base, index): if base == 0: print('can\'t calculate because base equal 0.') elif (not base == 0) , index == 0: print('the value 0, because base greater 1, , index equal 0.') elif (not base == 0) , index == 1: print('the answer equal base, because index equal 1. therefore, answer {ans}.'.format(ans=base)) elif (not base == 0) , index == 2: print('{b} squared {c}.'.format(b=base, c=(b ** 2)) elif (not base == 0) , (index > 2 or index < 0): print('{b} power of {i} equal {c}'.format(b=base, i=index, c=base**index)) # print function. print(square(b1, i1))
the error this:
line 36, elif (not base == 0) , (index > 2 or index < 0):
syntaxerror: invalid syntax
i use python 3.5.1. how can fix error?
the problem not on line, on line above. did not close enough parentheses. try adding close parenthesis end of previous line.
Comments
Post a Comment