This part of a program, I have to do. I have to take a strings, which for example might be s= 3 * 5
This part of a program, I have to do. I have to take a string"s", which for example might be s= " 3 * 5 + 1 " and properly calculate it. I need some help getting started, thanks. Also in python 3.6
def getNextNumber(expr, pos): #expr is a given arithmetic formula in string s #pos = start position in expr #1st returned value = the next number (None if N/A) #2nd returned value = the next operator (None if N/A) #3rd retruned value = the next operator position (None if N/A) if len(expr)==0 or not isinstance(expr, str) or pos<0 or pos>=len(expr) or not isinstance(pos, int): print("type mismatch error: getNextNumber") return None, None, "type mismatch error: getNextNumber" #--- function code starts ---#
#--- function code ends ---#
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started