python - Read inputs(nummbers) till a input (Stop) is given
问题描述
i want to Read inputs(nummbers) till a input (Stop) is given and then add all the nummber that are given before the input stop. idk what to do. here i tried but doesnt work at all.
input2 = input()
input3 = input()
input4 = input()
input5 = input()
som = 0
while input1 or input2 or input3 or input4 or input5 != "stop":
som = int(input1) + int(input2) + int(input3) + int(input4) + int(input5)
print(som)
break
if input1 or input2 or input3 or input4 or input5 == "stop":
print(som, "Stop")
解决方案
在循环语句中包含输入:
som = 0
while True:
number = input()
if number == "stop":
break
som += int(number)
print(som)
推荐阅读
- image - 如何在 Flutter 中显示选取的图像
- javascript - Python/Javascript 中的 API 密钥请求
- python - .any() 没有识别出真值
- python-3.x - Openslide:删除飞利浦 TIFF 文件的“标签”图像
- asp.net-mvc - 调用函数 onClick ASP.NET Core
- lambda - Java 8 函数式编程,收集 List 类型的流的输出
? - python - Django None Type 对象不可调用
- angular - Angular 10 - 有条件地动态加载特定的较少文件
- javascript - 如何使用 Jasmine 在 Angular 中模拟服务依赖项?
- exec - Azure Synapse 将 exec 的结果插入表中