<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2668" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>When I run the following code it just keeps repeating. Here is a screen
shot showing what I mean:</DIV>
<DIV>Mini Calculator<BR>By Nathan Pinno</DIV>
<DIV> </DIV>
<DIV>CALCULATE MENU<BR>1) Add<BR>2) Subraction<BR>3) Multiplication<BR>4)
Division w/o remainder<BR>5) Division with remaider<BR>6) Exponation<BR>7)
Square roots<BR>9) Exit<BR>Option: 5<BR>First number:4<BR>Second number:2<BR>4 /
2 = 2 R 0<BR>First number:3<BR>Second number:6<BR>3 / 6
= 0 R 3<BR>First number:5<BR>Second number:6<BR>5 / 6 =
0 R 5<BR>First number:</DIV>
<DIV> </DIV>
<DIV>Here is the relevant code:</DIV>
<DIV># This is a small calculator.<BR>def menu():<BR> print
"CALCULATE MENU"<BR> print "1) Add"<BR>
print "2) Subraction"<BR> print "3)
Multiplication"<BR> print "4) Division w/o
remainder"<BR> print "5) Division with
remaider"<BR> print "6) Exponation"<BR>
print "7) Square roots"<BR> print "9) Exit"</DIV>
<DIV> </DIV>
<DIV>def cal():<BR> global cal_opt<BR>
cal_opt = int(raw_input("Option: "))</DIV>
<DIV> </DIV>
<DIV>print "Mini Calculator"<BR>print "By Nathan
Pinno"<BR>print<BR>menu()<BR>cal()<BR>while cal_opt != 9:<BR>
if cal_opt == 1:<BR> X = input("First
number:" )<BR> Y = input("Second
number:" )<BR> print X, "+", Y, "= ",X
+ Y<BR> elif cal_opt ==
2:<BR> X = input("First number:"
)<BR> Y = input("Second number:"
)<BR> print X, "-", Y, "= ",X -
Y<BR> elif cal_opt ==
3:<BR> X = input("First number:"
)<BR> Y = input("Second number:"
)<BR> print X, "*", Y, "= ",X *
Y<BR> elif cal_opt ==
4:<BR> X = input("First number:"
)<BR> Y = input("Second number:"
)<BR> if Y ==
0:<BR> print
"Division by zero ot
allowed!"<BR>
Y = input("Second number:" )<BR>
else:<BR>
print X, "/", Y, "= ",X / Y<BR> elif cal_opt ==
5:<BR> X = input("First number:"
)<BR> Y = input("Second number:"
)<BR> if Y ==
0:<BR> print
"Division by zero ot
allowed!"<BR>
Y = input("Second number:" )<BR>
else:<BR>
print X, "/", Y, "= ",X / Y," R ", X % Y<BR> elif cal_opt ==
6:<BR> X = input("First number:"
)<BR> Y = input("Power:"
)<BR> print X, "**", Y, "=
",X**Y<BR> elif cal_opt ==
7:<BR> X = input("Number to find the
square root of:" )<BR> print "The
square root of", X, " = ",X**0.5<BR>
else:<BR> print "That's not an option.
Try again."<BR>
menu()<BR> cal()<BR>print
"Goodbye"</DIV>
<DIV> </DIV>
<DIV>How do I stop this, and make it go back to the main menu?</DIV>
<DIV> </DIV>
<DIV>Thanks in advance,</DIV>
<DIV>Nathan</DIV></BODY></HTML>