How do you create a Namedtuple in Python?
To create a named tuple in Python, follow these steps:
- Import the namedtuple class from the collections module.
- Now, the constructor shall take the name of the named tuple and a string containing the names of the field, separated by whitespace.
- The above action shall return a new namedtuple class for the specified fields.
- To use the new namedtuple, call the new class with all the values (in order) as parameters.
BY Best Interview Question ON 10 Jul 2020