Python built-in functions tutorials and examples

Python rstrip – remove training spaces and newline

Python rstrip can be used to removed trailing whitespaces (spaces, newlines, tabs, etc.) from a string. It Usage newstring = s.rstrip([chars]) If chars string is read more

Python type – find type of a variable

Python in-built function type() can be use to find type of any variable or value. Example – type() of string variable Example – type() of read more

Python find length of string or list using len()

Python len can be used to return length of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or read more

Python xrange examples

Python xrange can be used to generate a sequence of numbers with desired start number and gap. It is often used in for loops. It read more

Python range examples

Python range can be used to generate a range of numbers with desired start number and gap. It is often used in for loops. Usage: read more

Python itertools imap examples

Python itertools imap is efficient way of mapping and looping over a large iterable. Here is the usage for imap: itertools.imap(function, *iterables) The function should read more

Python itertools ifilter examples

Python itertools.ifilter is efficient way of filtering and looping over a large iterable. Here is the usage for ifilter: itertools.ifilter(function, iterable) The function should take read more

Python map examples

Python map is very useful built-in python function to achieve complex stuff over a list in very short and elegant way. Note that map applies read more

Python filter vs ifilter

Python filter is very handy python built-in function to filter iterables (e.g. lists) in python. But it returns a list which may consume huge memory read more

Python filter list/iterable examples

Python filter is very useful built-in python function to achieve complex stuff over a list in very short and elegant way. Note that filter applies read more

python print examples

Here are some examples you can print strings or variables in python on stdout. Print a string with newline in the end By default python read more