From 9abfba75cddc21f4d798b8ac74c67558179579ec Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Tue, 25 Jul 2023 12:05:05 +0800 Subject: [PATCH] save project --- func.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 func.py diff --git a/func.py b/func.py new file mode 100644 index 0000000..50b5d44 --- /dev/null +++ b/func.py @@ -0,0 +1,22 @@ + +def rice(): + total = [] + while True: + unit= input("请输入:") + if unit== 'q': + break + else: + try: + unit = int(unit) + except: + print("输入错误,请输入数字") + else: + total.append(unit) + return total +def sum(price): + a = 0 + for i in price: + a+=i + return a + +print(sum(rice())) \ No newline at end of file -- libgit2 0.25.0