×


Category: WordPress


Python String partition() Method - Explained with examples

This article covers the usage of the partition() method in Python. In fact, Python partition() function is used to partition a string at the first occurrence of the given string and return a tuple that includes 3 parts – the part before the separator, the argument string (separator itself), and the part after the separator.


Python partition() function partition() Parameters

The partition() function accepts a single parameter:

  • separator – a string parameter that separates the string at the first occurrence of it.
  • Note – If the separator argument is kept empty, then the Python interpreter will throw a TypeError exception.


Python List pop() Method - Explained with Examples

This article covers how to use the pop() method in Python. In fact, the pop() method removes the item at the given index from the list and returns the removed item.


pop() function parameters:

  • The pop() method takes a single argument (index).
  • The argument passed to the method is optional. If not passed, the default index -1 is passed as an argument (index of the last item).
  • If the index passed to the method is not in range, it throws IndexError: pop index out of range exception.


Return Value from pop()

The pop() method returns the item present at the given index. This item is also removed from the list.


Python split() Function

This article covers how to use the split() function in Python. In fact, The split() method breaks up a string at the specified separator and returns a list of strings.


split() Parameters

The split() method takes a maximum of 2 parameters:

  • separator (optional) - Delimiter at which splits occur. If not provided, the string is splitted at whitespaces.
  • maxsplit (optional) - Maximum number of splits. If not provided, there is no limit on the number of splits.


split() Return Value

The split() method returns a list of strings.


Python isnumeric() Method - Explained with Examples

This article covers how to use the isnumeric() method in Python. In fact, the isnumeric() method returns True if all characters in a string are numeric characters. If not, it returns False.

A numeric character has following properties:

  • Numeric_Type=Decimal
  • Numeric_Type=Digit
  • Numeric_Type=Numeric


Python isinstance() Function - Explained with examples

This article covers how to use the isinstance() function in Python. In fact, the isinstance() function checks if the object (first argument) is an instance or subclass of classinfo class (second argument).


isinstance Return Value

isinstance() returns:

  • True if the object is an instance or subclass of a class or any element of the tuple.
  • False otherwise.


If classinfo is not a type or tuple of types, a TypeError exception is raised.