← Lesson
Lists
Joeven
Run
Reset
Python loads on first run
memory = ["user: book a flight", "thought: need dates"] print("first:", memory[0]) print("last:", memory[-1]) print("from index 1:", memory[1:]) print("count:", len(memory)) memory.append("action: ask_user") print("after append:", memory) print("ask_user in list?", "action: ask_user" in memory) undone = memory.pop() print("popped:", undone) print("now:", memory) step = ["action", ["search", "weather"]] print("inner first:", step[1][0]) # append changes the list and gives back None print("append returns:", memory.append("obs: next week")) print("memory is still a list:", memory)
Run to execute this in your browser. Nothing is sent to a server.