Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_2
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
192928a8
authored
Feb 12, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
7b52fe6f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
4.py
6.py
4.py
View file @
192928a8
def
new_input
():
#新建一个函数
def
new_input
():
#新建一个函数
total
=
[]
#建立一个空价格列表
total
=
[]
#建立一个空价格列表
while
True
:
while
True
:
uni
t
=
input
(
"请输入(q退出):"
)
#输入内容的提示
monetmone
t
=
input
(
"请输入(q退出):"
)
#输入内容的提示
if
unit
==
"q"
:
#如果输入q
if
unit
==
"q"
:
#如果输入q
break
#终止程序
break
#终止程序
else
:
#否则
else
:
#否则
try
:
try
:
unit
=
int
(
unit
)
#输入一个整数
unit
=
int
(
unit
)
#输入一个整数
except
:
#
except
:
#
print
(
"请输入一个数字"
)
如果我输入的不是整数的提示
print
(
"请输入一个数字"
)
#
如果我输入的不是整数的提示
else
:
else
:
total
.
append
(
unit
)
#如果我输入的是整数的话就把这个整数添加到total中
total
.
append
(
unit
)
#如果我输入的是整数的话就把这个整数添加到total中
print
(
"-"
*
30
)
#一个分界线
print
(
"-"
*
30
)
#一个分界线
...
...
6.py
0 → 100644
View file @
192928a8
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
)
\ 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