如何在 python 中的每个命令后添加积分
How to add the integral after every command in python
我有问题。
我想创建一个名为 admr 的列表,但不知道如何在每个命令后添加积分。太难解释了所以我写下下面的例子。
有人能帮帮我吗?谢谢。
我的代码:
mr=[]
def records():
return
def add(records):
records = input('Add description and amount:\n').split()
mr.append(records)
while True:
command = input('\nWhat do you want to do (add / view)? ')
if command == 'add':
records = add(records)
我想要的是:
input add() : Tree 50
mr = [['tree', '50']]
admr = [['tree', '50', '1']]
input add() : Fun 100
mr = [['tree', '50'],['Fun', '100']]
admr = [['tree', '50', '1'],['Fun', '100', '2']]
这是您要找的吗?
# Starting with records = ['tree', '50']
# Get length of array with len(array)
# Increment by one
# Convert to string to match your result
records.append(str(len(mr)+1))
# Ending with records = ['tree', '50', '1']
admr.append(records)
我有问题。
我想创建一个名为 admr 的列表,但不知道如何在每个命令后添加积分。太难解释了所以我写下下面的例子。
有人能帮帮我吗?谢谢。
我的代码:
mr=[]
def records():
return
def add(records):
records = input('Add description and amount:\n').split()
mr.append(records)
while True:
command = input('\nWhat do you want to do (add / view)? ')
if command == 'add':
records = add(records)
我想要的是:
input add() : Tree 50
mr = [['tree', '50']]
admr = [['tree', '50', '1']]
input add() : Fun 100
mr = [['tree', '50'],['Fun', '100']]
admr = [['tree', '50', '1'],['Fun', '100', '2']]
这是您要找的吗?
# Starting with records = ['tree', '50']
# Get length of array with len(array)
# Increment by one
# Convert to string to match your result
records.append(str(len(mr)+1))
# Ending with records = ['tree', '50', '1']
admr.append(records)