# I am a beginner and I wanted to add a loop in my calculator program so that I don't need to run it again and again. What can I do?

calculator.py A simple calculator program.

``````def main(): print ("CALCULATOR")

operation = eval(input("Type the operation you want to perform:"))

main ()
``````

On Best Solutions

Just wrap is around a infinite loop, one way of doing it is `while True`

``````def main():
print ("CALCULATOR")

operation = eval(input("Type the operation you want to perform:"))

#Infinite loop
while True:
main()
``````

This will give you

``````CALCULATOR
Type the operation you want to perform:5+7
CALCULATOR
Type the operation you want to perform:4*6
CALCULATOR
Type the operation you want to perform:
``````

In order to break the `while True` loop at some point, you would want to come up with a word, say `quit` and when the use types it, you exit out of the infinite loop using `exit()`

``````def main():
print ("CALCULATOR")

#Take operation from user
operation = input("Type the operation you want to perform, else type quit to exit:")

#If quit is typed exit
if operation == 'quit':
exit()

#Else evaluate and print result
operation = eval(operation)

#Infinite loop
while True:
main()
``````

This will give you

``````CALCULATOR
Type the operation you want to perform, else type quit to exit:6+7