Latest Posts From Safa Mulani

Python Set Difference

Python Set Difference basically performs the difference operation on iterable objects and the result contains the difference between them. It contains elements that are present in the set (on which the operation is invoked) which are not present in the other sets. Python Set Difference Venn Diagram The below Venn diagram provides a much better […]

Python String ljust() and rjust() functions

Python String contains two built-in methods to provide the left and right justification. 1. Python String ljust() function Python String ljust() function accepts the character for padding it to the input string. Then, it substitutes the character and does padding to the right of the input string. Syntax: Parameters: length: The value of the length […]

Python slice() function

Python slice() function returns a sliced object from the set of indexes of the input specified by the user in accordance with the arguments passed to it. Thus, it enables the user to slice any sequence such as Lists, Tuples, Strings, etc. Syntax: Start: (Optional) An integer that specifies the index to initiate the slicing […]

Python Set Union

Union basically represents all the distinct elements of the corresponding sets altogether. Python Set union() method finds the union of the sets and represents a new set which contains all the items from the corresponding input sets. Note: If a set contains an element that appears more than once, then the output represented contains only […]

Python Add to Dictionary

Python Dictionary basically contains elements in the form of key-value pairs. It is an unordered collection of items. Creation of Dictionary: Output: How to Add to Dictionary in Python By using update() method By using _setitem_() method By using subscript notation By using “*” operator 1. By Using update() Method The update() method enables the […]

Python Set Intersection

Python Set Intersection basically finds and returns elements common among the sets. Syntax: set1.intersection(set2) is equivalent to set1 ∩ set2. Arguments: Accepts one or more sets as an argument. Return Value: Returns a set as output which contains elements common to all the sets. Ways to achieve Set Intersection in Python Either of the following […]