// LIST BUILDER
// LIVE CODE
my_list = []
// INDEXING EXPLORER
Build a list in Panel 1, then explore it here.
INDEX CELLS
list is empty
index
slice
result will appear here
// NEGATIVE INDEXING
my_list[-1]
# last item
my_list[-2]
# second to last
my_list[1:3]
# items at index 1, 2
// COMMON METHODS
len(my_list)
# length
my_list.append(x)
# add to end
my_list.sort()
# sort in place
// FILE OPERATIONS
with open("file.txt", "r") as f:
content = f.read()
with open("file.txt", "w") as f:
f.write("Hello, world!")
with open("file.txt", "r") as f:
lines = f.readlines()
for line in lines:
print(line.strip())
def main():
print("Running!")
if __name__ == "__main__":
main()