Reverse a word in python | Letters in word and Sentences

It a very easy to Reverse words in a string python, you have to first Separate each word, then Reverse the word separated list, and in the last join each word with space. For all this step you needed a split(), join() , reversed() function and list data structure. Algorithm of reverse words in a sentence Read More…


Python slice string Function| Get a range of characters (SubString)

You can get a range of characters(substring) by using the slice function. Python slice() function returns a slice object that can use used to slice strings, lists, tuples. You have to Specify the parameters- start index and the end index, separated by a colon, to return a part of the string. Syntax slice(start_pos, stop_pos, step) Read More…


Python reverse string | Using loop, recursion, stack, slice, reversed

The string is a sequence of character data. There is no built-in function to reverse a string. But you can use slice, loop, recursion, reversed, join, etc function to reverse a string in python. Way to Python reverse string Loop – for-loop slice Recursion reversed with join() stack Example of Python reverse string We will see Read More…


Python sort list of tuples | descending, first, second, last, multiple elements, value, alphabetically

Python sort list of tuples using the sort method needed key which sorts lists in place. And also offers a convenient way to sort tuples based on the index of tuple elements. You can sort the list of tuples by first and second elements by using indexes or values. tup[0] to sort on first tuple element tup[1] to Read More…


Python iterable object | Lists, tuples, dictionaries, and sets

Python iterable objects are capable of returning their members one at a time, permitting them to be iterated over in a for-loop. Examples of iterable include all sequence types (such as list, str, and tuple) and some non-sequence types like dict, file objects, and objects of any classes you define with an __iter__() or __getitem__() method. Remember:- Read More…


Python frozenset() Function | immutable List, Tuple, Dictionary Examples

What is Python frozenset and frozenset() function? Python frozenset is an immutable object and frozenset() method returns a frozenset object initialized with elements from the given iterable. The frozenset() is an inbuilt function in Python. More about Frozen set: It’s just an immutable version of a Python set object. While elements of a set can modify elements but frozen set Read More…


Python sorted function | Sort string, list, tuple, dictionary

Python sorted() function is used to sort string, list, tuple, dictionary, etc and it returns a list with the elements in a sorted manner, without modifying the original sequence. Syntax sorted(iterable, key=key, reverse=reverse) Parameter Values The sorted() method takes an of three parameters: iterable – A sequence or collection or any other iterator. reverse (Optional) – If True, Read More…


Python sort list of strings | Alphabetically & Number

Task: You have a list of strings and you have to sort it. There can be multiple scenarios possible while sorting a list of a sting in python, like:- Sorting in alphabetical/reverse order. Sort list of strings with numbers Based on the length of string character Let’s see one by one every possible scenarios examples. How Read More…


Python sort list (Array) Alphabetically Example | data structure

How to sort the words alphabetically in List? Given List:- Answer: You can use the sort() or sorted() python function for sort lists alphabetically in python. sort() function – will modify the list it is called on. sorted() function- will create a new list containing a sorted version of the list it is given Example of sort list alphabetically Read More…


Python reverse list | with reverse() function & Other ways

You can reverse Python List using an inbuilt reverse() function and other ways. The python reverse() function is mainly used to reverses the elements of a given list(Array). In this tutorial, our main top will be the reverse() function. Syntax doesn’t take any argument. list.reverse() Return Value It Doesn’t return any value. List elements will Read More…