diff --git a/__pycache__/func.cpython-37.pyc b/__pycache__/func.cpython-37.pyc new file mode 100644 index 0000000..69afc4f 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..6a2ddb4 --- /dev/null +++ b/func.py @@ -0,0 +1,25 @@ +def new_input(): + total = [] + while True: + unit= input("请输入:") + if unit =='q': + break + else: + try: + unit=int(unit) + except: + print("enter a number") + else: + total.append(unit) + return total + +def sum(money): + count=0 + for i in money: + count = count+i + return count +result=new_input() +p=sum(result) +print(p) + + diff --git a/swim.py b/swim.py new file mode 100644 index 0000000..0ee59f1 --- /dev/null +++ b/swim.py @@ -0,0 +1,6 @@ +import func + +data = func.new_input() +score = func.sum(data) + +print(score) \ No newline at end of file