diff --git a/func.py b/func.py index 8599041..23569df 100644 --- a/func.py +++ b/func.py @@ -1,15 +1,22 @@ -total = [] -while True: - unit= input("请输入:") - if unit== 'q': - break - else: - try: - money = int(money) - except: - print("udhbehbhetuhwi") - else: - total.append(unit) +def new_input(): + total = [] + while True: + unit= input("请输入:") + if unit== 'q': + break + else: + try: + unit = int(unit) + except: + print("udhbehbhetuhwi") + else: + total.append(unit) return total +def sum(list): + count=0 + for i in list: + count=count+i + return count a = new_input() -print(a) \ No newline at end of file +b=sum(a) +print(b) \ No newline at end of file