Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f5350e04
authored
May 17, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
e837167e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
func.py
func.py
View file @
f5350e04
total
=
[]
#总的价格
def
new_input
():
while
True
:
#重复执行
total
=
[]
#总的价格
unit
=
input
(
"请输入:"
)
#输入价格
while
True
:
#重复执行
if
unit
==
'q'
:
#如果输入是q
unit
=
input
(
"请输入:"
)
#输入价格
break
#退出循环
if
unit
==
'q'
:
#如果输入是q
else
:
break
#退出循环
total
.
append
(
unit
)
列表里追加新元素
else
:
#否则
print
(
total
)
try
:
#尝试输入
\ No newline at end of file
unit
=
int
(
unit
)
except
:
#如果错了就会打印下面的内容
print
(
"请输入一个数字"
)
else
:
#输入正确显示
total
.
append
(
unit
)
#列表里追加新元素
print
(
total
)
#显示到列表
new_input
()
#调用函数
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment