Commit 83e65c31 by BellCodeEditor

auto save

parent 578e41ee
Showing with 38 additions and 9 deletions
total = [] #定义函数实现价格输入
while True: def new_input():
unit= input("请输入:") total = []
if unit== 'q': while True:
break unit = input('请输入(q退出):')
else: if unit == 'q':
total.append(unit) break
print(total) else:
\ No newline at end of file try:
unit = int(unit)
except:
print("请重新输入一个数字")
else:
total.append(unit)
print("-"*30)
#返回值类型:列表
return total
#定义函数实现价格列表中的价格求和,参数类型为列表
def sum(money):
count = 0
for i in money:
count = count + i
#返回值类型:整型
return count
result = new_input()
count = sum(result)
print(count)
\ No newline at end of file
try:
age = int(input('你今年几岁了?'))
except:
print('要输入整数哦!')
else:
if age < 18:
print('不可以喝酒哦')
print('程序结束~')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment