I am Hack Sparrow
Captain of the Internets.

Python: length or size of list, tuple, array

Let me clarify something at the beginning, by array, you probably mean list in Python. list is the equivalent of arrays in JavaScript or PHP. Arrays in Python is an altogether different thing. Ok, having cleared that, getting the the size of a list or tuple (or array, if you will), is pretty straighforward. You just call the l ...

Python: difference between list and tuple

To put it lightly, tuples are lists which can't be edited. Once you create a tuple, you cannot edit it, it is immutable. Lists on the other hand are mutable, you can edit them, they work like the array object in JavaScript or PHP. You can add items, delete items from a list; but you can't do that to a tuple, tuples have a fixed size. Here is an example demonstrating the mutable nature of lists in Python. [code] >>> anima ...

Python: split string method and examples

So you are looking to break up a string into smaller strings (in an array if you are coming from a PHP / JavaScript background) based on a delimiter or character. Python provides a very straightforward and easy function to do that. The function is called split, it returns a list as the result (you really don't want to a Python array for this one) and here are some examples. Examples 1 to 3 are to be tri ...