python - 未调用 Python 函数。只能打印我的打印语句中的问题
问题描述
history = []
print("Options: 1) Integer Summation, 2) String concatenation, 3) Last Display, 4)Exit...")
def main():
def summation():
first_num = int(input("Type the first integer: "))
second_num = int(input("Type the second integer: "))
total_0 = first_num + second_num
print("Sum of two integers is: ",total_0)
history.append(total_0)
def string():
first_num = str(input(":ype the first string: "))
second_num = str(input("Type the second string: "))
total_1 = first_num + second_num
history.append(total_1)
print("Concatenation of two strings is: ",total_1)
def last():
print("The Previous result is: " + str(history()))
def exits():
print("Exiting...")
while True:
x = str(input("Type your option: "))
if x == "1" or x == "2" or x == "3" or x == "4":
break
if x == "1":
summation()
elif x == "2":
string()
elif x == "3":
last()
else:
exits()
main()
解决方案
你的while的缩进是错误的。它应该在您的主要功能中。
推荐阅读
- html - 容器流体中的中心容器
- swift - swift 'FIRInvalidArgumentException',原因:'不支持的类型:NSURL(在字段 AccountTypeImageURL 中找到)'
- sql - 在单个查询中通过 oracle 获取基于优先级的单个记录
- wpf - 如何在 wpf 中调整 3d 模型的大小?
- three.js - 三个js轨道控制设置角度
- batch-file - SET /a var1 = var1 + 1 /a 不是内部或外部命令
- javascript - 如何使用数组渲染一组孩子
- http - http 缓存,使用 must-revalidate
- ios - DateFormatter 在 iPhone 上返回 nil,但在模拟器上不返回
- compilation - 无法运行 Base.compilecache:“在路径中找不到”