We can use zip() function to produce an iterable from two tuple objects, each corresponding to key and value items and then use dict() function to form dictionary object , Dictionary comprehension syntax can also be used to construct dictionary object from two tuples ,
Python’s standard library contains built-in function set() which converts an iterable to set. A set object doesn’t contain repeated items. So, if a string contains any character more than once, that character appears only once in the set object. Again, the characters may not appear in the same sequence as in the string as set() function has its own hashing mechanism ,
Since Python 3.0, it is no longer possible to define unpacked tuple as a parameter in a function (PEP 3113). It means if you try to define a function as below: , Python interpreter displays syntax error at first bracket of tuple. Instead, define tuple objects as parameter and unpack inside the function. In following code, two tuple objects representing x and y coordinates of two points are .....
The index() method available to List (as well as other sequence type such as string and tuple) is useful to find first occurrence of a particular element in it. , To obtain indexes of all occurrences of an element, create enumerate object (which presents iterator for index and value of each element in list) ,
Sign up now to get your own personalized profile!
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more