How can I convert a string to an int in Python?

前端 未结 8 1481
北恋
北恋 2020-11-27 21:35

The output I\'m getting for my little example app is the following:

Welcome to the Calculator!
Please choose what you\'d like to do:
0: Addition
1: Subtracti         


        
8条回答
  •  囚心锁ツ
    2020-11-27 22:21

    def addition(a, b): return a + b
    
    def subtraction(a, b): return a - b
    
    def multiplication(a, b): return a * b
    
    def division(a, b): return a / b
    
    keepProgramRunning = True
    
    print "Welcome to the Calculator!"
    
    while keepProgramRunning:
     print "Please choose what you'd like to do:"
    

提交回复
热议问题