Book I am reading from suggest that I make a program using functions, whiles and if.
The purpose of this program is:
Take 4 numbers from the user, 2 will be summed, 2 will be subtracted.
There are 3 functions. One is procedure_1, it is a while, it is supposed to take numbers from the user and continue the process until sum reaches <= 100 and sub reaches a value of <= 100, it also puts the results of these procedures on a list. In case it does, start() function has an if that, in case it reaches those values, it will run procedure_2, which prints a message and also prints the results of the lists.
Heres the code, but I am getting:
print "Results of sum and subtract:... %d, %d" % (sum, rest)
^
IndentationError: unindent does not match any outer indentation
sum = 0
rest = 0
results = []
results_2 = []
def procedure_1():
while sum <= 100 and rest <= 100:
sum = n1 + n2; rest = ns1 - ns2
print "What numbers do you wish to sum and subtract?"
n1 = raw_input("Sum Num1:...")
n2 = raw_input ("Sum num2:...")
ns1 = raw_input("Sub Num 1:...")
ns2 = raw_input ("Sub Num 2:...")
print "Results of sum and subtract:... %d, %d" % (sum, rest)
results.append(sum); results_2.append(rest)
sum += sum; rest += rest
def procedure_2():
print "Values are too high to compute your stuff"
for sum in results:
print sum
for rest in results_2:
print rest
def start():
if sum < 100 and rest < 100:
procedure_1()
else:
procedure_2()
Checked and double checked it, still cant run it and see whats wrong with it, would appreciate advice on how to make this code work too. Thanks a lot.