diff --git a/__pycache__/func.cpython-37.pyc b/__pycache__/func.cpython-37.pyc new file mode 100644 index 0000000..76aa7f1 Binary files /dev/null and b/__pycache__/func.cpython-37.pyc differ diff --git a/func.py b/func.py new file mode 100644 index 0000000..8706f58 --- /dev/null +++ b/func.py @@ -0,0 +1,29 @@ +def sum(a): + rt=0 + for i in a: + rt+=i + + return rt +def new_input(): + total = [] + while True: + money = input('请输入(q退出):') + if money == 'q': + break + else: + try: + money = int(money) + except: + print("请重新输入一个数字") + else: + total.append(money) + finally: + print("-"*30) + return total + + +result = new_input() +print(result) +c=new_input() +b=sum(c) +print(b) diff --git a/list.py b/list.py new file mode 100644 index 0000000..789abb9 --- /dev/null +++ b/list.py @@ -0,0 +1,4 @@ +import func +livt=func.new_input() +sd=func.sum() +print(sd) \ No newline at end of file