本周我开始认真学习python(这是我计划学习的第一门语言),今天我写了这个待办事项列表脚本。我实现了add、remove和view特性,但是现在我希望能够添加到期时间,并标记是否完成。我该怎么做?提前谢谢!代码如下
list = []
def add():
global itemadd
itemadd = input("What would you like to add?")
list.append(itemadd)
print("You've added " + itemadd + " to your to-do list. Here is what your list currently looks like:")
print(list)
def remove():
print(list)
global itemremove
itemremove = input("What would you like to remove?")
if itemremove in list:
list.remove(itemremove)
else:
while itemremove not in list:
print("This item is not on your to-do list. Did you spell it correctly?")
itemremove = input("Try again:")
print("You have removed " + itemremove + " from your to-do list. Here is what your list currently looks like:")
print(list)
def prompt():
ask = input("What would you like to do? (add an item (add), view list (view), remove an item (remove))")
if ask == "add":
add()
elif ask == "view":
print("Here is your to-do list:")
print(list)
elif ask == "remove":
remove()
stop = False
while not stop:
prompt()
您可以创建一个类来记录需要做的每件事,并创建另一个类来保存要做的事:
然后实现
add_thing
、remove_thing
、update_status
、archive_thing
、reprogram_thing
等方法相关问题 更多 >
编程相关推荐