Python rstrip Function | trim string from right

Python rstrip function is used to remove trailing characters (characters at the end of a string). Whitespace is the default trailing character to remove if no character is passed as a parameter. If you want to remove (trim string):- All leading White-space – use Python lstrip Function. Leading and trailing spaces- use Python string strip() Read More…


Python lstrip Function | trim string from left examples

Python lstrip() method is used to remove all leading White-space (characters) from the string. There is an option in “lstrip Function” to use or not a char type parameter. If the parameter is not provided, it removes all the leading spaces from the string. Read more topic & links If you want Remove Both side space form Read More…


Python trim string | Python string strip() function

You can trim string in python using a strip() function. It removes the leading and trailing spaces of a given String. There are 2 more methods “lstrip() and rstrip()” that can use to remove leading or trailing whitespaces. Note: default whitespace characters will remove, you can remove other char also. Method to trim Strings in Read More…


Python string count function | Count total characters in string & occurrences

The python string count function is used to get the number of occurrences of a substring in the given string. The means count() method will search the substring in the given string and returns how many times the substring is had it. Note: count() function is case sensitive, which means if you find caps lock word then Read More…


Python length of list | Get List size | len() Function

To get the length of the list in python you can use the len() function. Len() Function is an inbuilt function in python and returns a number of elements present in the list object. Syntax len(list) Return Value This method returns the number of items in the list. Example of get size of list Python # Read More…


Python list insert Function | at End, Front, List into List Examples

Python list insert function is used to insert (add) elements in List. insert() is an inbuilt function in Python. With the insert() method you can inserts the specified value at the specified position. Syntax list.insert(index, element) Parameters index – where an element needs to be inserted. (Required) element – this is the element to be inserted in the Read More…


Python list pop function | Remove element from the list

Python list pop function is used to removes the element at the given index from the list and it returns the removed item. So basically you can remove the element at the specified position by using the pop() Method in Python List. Note: Index in Python List starts from 0, not 1. Syntax list.pop(index) Parameter index (optional) Read More…


Python clear list | Remove all items in Python list

You can clear a Python list by using the clear() function. Python clear() function removes all items from the list. There are many ways to do delete or remove all items from the Python list. Syntax list.clear() Example of Python clear list The clear() method doesn’t take any parameters and doesn’t return any value. It’s Read More…


Python list remove() function | remove elements by value

You can use the “Python list remove() function” to remove elements (items) from the list. Python lists also have other methods clear(), pop(), and remove() are used to remove items (elements) from a list. In this tutorial we will see examples of only Python list remove function. A remove() is an inbuilt function in Python that Read More…


Python remove single quotes from a string | (‘)

You can remove single quotes from a string in python using replace the function or translate function, Regular Expressions, etc. A easiest way is just replace the apostrophe character with an empty string: msg = “Hell’o” print(msg.replace(“‘”, “”)) Way to remove single quotes from a string in Python replace() function translate() function Regular Expressions Other Read More…