Commit 5b50be17 by BellCodeEditor

save project

parent c7dcd746
Showing with 58 additions and 19 deletions
def new_input():
totol =[]
while True:
unit=input('请输入单价(q退出)')
if unit=='q':
break
else:
try:
unit= int(unit)
except:
print("输入一个数字")
else:
totol.append(unit)
finally:
print("-"*30)
print(totol)
new_input()
\ No newline at end of file
...@@ -5,6 +5,7 @@ except: ...@@ -5,6 +5,7 @@ except:
print("结束啦") print("结束啦")
total = [] total = []
def csy(): def csy():
while True: while True:
...@@ -14,6 +15,10 @@ def csy(): ...@@ -14,6 +15,10 @@ def csy():
else: else:
total.append(unit) total.append(unit)
csy() csy()
print(total) print(total)
...@@ -36,3 +41,55 @@ def new_input(): ...@@ -36,3 +41,55 @@ def new_input():
print(totol) print(totol)
new_input() new_input()
def new_input():
totol =[]
while True:
unit=input('请输入单价(q退出)')
if unit=='q':
break
else:
try:
unit= int(unit)
except:
print("输入一个数字")
else:
totol.append(unit)
finally:
print("-"*30)
return totol
abc = new_input()
print (abc[1])
def new_input():
totol =[]
while True:
unit=input('请输入单价(q退出)')
if unit=='q':
break
else:
try:
unit= int(unit)
except:
print("输入一个数字")
else:
totol.append(unit)
finally:
print("-"*30)
return totol
abc=new_input()
sum_a=0
for i in abc:
sum_a=sum_a+i
print(sum_a)
\ 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