Python list() Function26 Sept 2024 | 1 min read The python list() creates a list in python. SignatureParametersiterable (optional) - An object that can be a sequence( string, tuple etc.) or collection( set, dictionary etc.) or iterator object. ReturnIt returns a list. Python list() Function Example 1The below example create a list from sequence: string, tuple and list. Output: [] ['a', 'b', 'c', 'd', 'e'] [1,2,3,4,5] [1,2,3,4,5] Explanation: The above example creates a list from sequence: string, tuple and list. Python list() Function Example 2The below example create list from collection: set and dictionary. Output: ['e', 'c', 'd', 'b', 'a'] ['c', 'e', 'd', 'b', 'a'] Next TopicPython Functions |
Function In python, a set is a built-in class, and this function is a constructor of this class. It is used to create a new set using elements passed during the call. It takes iterable as an argument and returns a new set object. The...
1 min read
Function Python has() function is used to get the hash value of an object. Python calculates the hash value by using the hash algorithm. The hash values are integers an used to compare dictionary keys during a dictionary lookup. We can hash only these types: Hashable types:...
2 min read
Function The python bytes() function in Python is used for returning a bytes object. It is an immutable version of bytearray() function. It can create empty bytes object of the specified size. Signature bytes(source) bytes(encoding) bytes(error) Parameters source is used to initialize the bytes object. It is an optional parameter. encoding is optional unless...
1 min read
Function converts a specified value into a string. Signature str(object, encoding=encoding, errors=errors) Parameters object : It is the encoding of the object. The default value is UTF-8. encoding : It is the encoding of the object. The default value is UTF-8. errors : It specifies the actions that need to...
1 min read
Function The python bytearray() function returns a bytearray object and can convert objects into bytearray objects, or create an empty bytearray object of the specified size. Signature bytearray(x, encoding, error) Parameters x (optional) : It is the source that initializes the array of bytes. encoding (optional) : It is an...
1 min read
Function The python open() function opens the file and returns a corresponding file object. Signature open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) Parameters file: It is a path like object giving the pathname of the file to be opened. mode (optional): It specifies the mode in which the file is...
2 min read
Function A python callable() function in Python is something that can be called. This built-in function checks and returns True if the object passed appears to be callable, otherwise False. Signature callable(object) Parameters object - The object that you want to test and check, it is callable or...
1 min read
Function The python hasattr() function returns true if an object has given named attribute. Otherwise, it returns false. Signature hasattr(object, attribute) Parameters object: It is an object whose named attribute is to be checked. attribute: It is the name of the attribute that you want to search. Return It returns true if an...
1 min read
Function function is used to get an octal value of an integer number. This method takes an argument and returns an integer converted into an octal string. It throws an error TypeError if argument type is other than an integer. The signature of oct() function is...
1 min read
Function function is used to compute the powers of a number. It returns x to the power of y modulus z if a third argument(z) is present, i.e. (x, y) % z. Signature pow(x, y, z) Parameters x: It is a number, a base y: It is a number, an...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India