缓存python Pythonista新手q

时间:2018-07-25 16:40:22

标签: python python-3.x caching

我正在尝试制作一个简单的待办事项列表程序,您可以在其中将内容输入列表,然后将其删除,或者检查该项目是否在列表中。

出现“未定义名称介绍”错误。我可以删除第一行“ intro()”代码,运行代码(什么都没有发生),然后将“ intro()”放回顶部,这样就可以正常运行。我相信这与python ide如何缓存数据有关,但是我不确定,因为我是编码和尝试通过互联网自学的新手。只是想熟悉一些基本概念。

我在iPad上使用Pythonista。

我试图清除缓存,但这不起作用。我也尝试过更改代码,然后运行控制台,但是它并没有更改代码应输出的内容,例如,我会将诸如“这是您的列表:”的简单内容更改为“这是您的列表!”。 !!”并且在运行程序后,感叹号仍然不会显示。

list = []

intro()

def intro_7():
    print("here is your list:")
    print(list)
    return intro_4()

def intro_6():
    checkinput = input("what would you like to make sure is on your list?")

    if list.count(checkinput) == True:
        print(checkinput)
        print("is on your list!")
        return intro_4()

    if list.count(checkinput) == False:
        addcheck = input("is not on your list, would you like to add it? y/n")
    if addcheck == "y":
        list.append(checkinput)
        print(list)
        return intro_4()
    if addcheck == "n":
        print("alright, we wont add it to the list")
        return intro_4()

def intro_5():
    subtractinput = input("what would you like to subtract?")
    list.remove(subtractinput)
    print(list)
    return intro_4()

def intro_4():
    addorsubtract = input("alright, now would you like to add, subtract, check or print the list?")
    if addorsubtract == "add":
        return intro_3()
    if addorsubtract == "subtract":
        return intro_5()
    if addorsubtract == "check":
        return intro_6()
    if addorsubtract == "print":
        return intro_7()


def intro_3():
    addinput = input("what would you like to add to the list?")
    list.append(addinput)
    print(list)
    return intro_4()


def intro_2():
    print("Now we're talking.'")
    return intro_3()

def intro():
    print("Hello Jacob,")

    begin = input("Would you like to start a list?? [y/n]")

    if begin == "y":
        print("Alright")
        return intro_2()
    if begin == "n":
        return intro()

0 个答案:

没有答案