hello there,

this is a simple deconstructed calculator i made, but i made a mistake somewhere i cant figure it out, please help.

def split(string):

list = [] #create an empty list for the loop to add numbers and operators in each index

blank = ''

for i in range(len(string)):

if string[i] == ‘+’ or string[i] == ‘-’ or string[i] == ‘*’ or string[i] == ‘/’ or string[i] ==’%’:
if string[i+1] == '*’ or string[i+1] == ‘/’: #In case the operator is ** or //

combine = string[i] +string[i+1] #put it in the same string in the same index

list.append(blank) #add to the list

list.append(combine)

blank = ‘’ #reasigning blank so it can do the job again without adding the previous variable in the second index

else:

if string[i-1] == ‘

*’ or string[i-1] == ‘/’:*

continue

else:

list.append(blank)

list.append(string[i])

blank = ‘’ #reasigning the blank again

elif 48 <= ord(string[i]) <= 57: #If the loop runs through a number, put them in an index

blank = blank+string[i]

if i==len(string) - 1:

list.append(blank)

return list

def calculation(string): #Function for calculating

i = 0

list = split(string)

while i <len(list): #Create a loop that runs through the list

if list[i] == ‘+’: #if it runs through an index that has '+'

calculate = int(float(list[i-1])) + int(float(list[i+1])) #the plus sign is i, so we use the index before and after the plus sign -which are numbers, add them together and put it in a storage

del list[i+1] #delete the two indexs that has numbers

del list[i-1]

list[i-1] = str(calculate) #if we delete [i-1], it means [i] is now [i-1], reasign it with the result in the storage, turn it into string

i = 0

if list[i] == ‘-’:

calculate = int(float(list[i-1])) - int(float(list[i+1]))

del list[i+1]

del list[i-1]

list[i-1] = str(calculate)

i = 0 #the same for other operations

if list[i] == '’:

continue

else:

list.append(blank)

list.append(string[i])

blank = ‘’ #reasigning the blank again

elif 48 <= ord(string[i]) <= 57: #If the loop runs through a number, put them in an index

blank = blank+string[i]

if i==len(string) - 1:

list.append(blank)

return list

def calculation(string): #Function for calculating

i = 0

list = split(string)

while i <len(list): #Create a loop that runs through the list

if list[i] == ‘+’: #if it runs through an index that has '+'

calculate = int(float(list[i-1])) + int(float(list[i+1])) #the plus sign is i, so we use the index before and after the plus sign -which are numbers, add them together and put it in a storage

del list[i+1] #delete the two indexs that has numbers

del list[i-1]

list[i-1] = str(calculate) #if we delete [i-1], it means [i] is now [i-1], reasign it with the result in the storage, turn it into string

i = 0

if list[i] == ‘-’:

calculate = int(float(list[i-1])) - int(float(list[i+1]))

del list[i+1]

del list[i-1]

list[i-1] = str(calculate)

i = 0 #the same for other operations

if list[i] == '

calculate = int(float(list[i-1])) * int(float(list[i+1]))

del list[i+1]

del list[i-i]

list[i-1] = str(calculate)

i = 0

if list[i] == ‘/’:

calculate = int(float(list[i-1])) / int(float(list[i+1]))

del list[i+1]

del list[i-i]

list[i-1] = str(calculate)

i = 0

if list[i] == ‘**’:

calculate = int(float(list[i-1])) ** int(float(list[i+1]))

del list[i+1]

del list[i-i]

list[i-1] = str(calculate)

i = 0

if list[i] == ‘//’:

calculate = int(float(list[i-1])) // int(float(list[i+1]))

del list[i+1]

del list[i-i]

list[i-1] = str(calculate)

i = 0

if list[i] == ‘%’:

calculate = int(float(list[i-1])) % int(float(list[i+1]))

del list[i+1]

del list[i-1]

list[i-1] = str(calculate)

i = 0

i = i +1

return int(float(list[0]))

print('Warning! This program does not calcucate operations in BODMAS. ')

x = str(input(‘Type in the operation you want to calculate:’)) #input for the calculation

for c in x:

if (97 <= ord© <= 122) or (65 <= ord© <= 90): #If one or more chacracters in the string are upercase or lowercase characters

print(‘Your input should be an operator.’) #Give a warning

break

else:

print(calculation(x)) #If it is an operator, do the calculation

break