In python:
Python Docs: More on List Objects Programming BitsCreate an empty list: my_list = [] Add an element to a list: my_list.append("some string") my_list.append(7) this list will now have two elements my_list[0] will contain "some string" and my_list[1] will contain the integer value of 7 Length of a list: find out the number of elements in a list -- just like finding the length of a string len(my_list) Insert an element at a given position in the list: a_list = ["some words", "in a","simple", "list" ] a_list.index(1,"and strings") a_list will now contain: ["some words","and strings", "in a","simple", "list" ] |
06.0 Python > Python Notes >