Question: Create a list of a tuple based on the length of the tuple where all elements but the last element is inside the tuple and

Create a list of a tuple based on the length of the tuple where all elements but the last element is inside the tuple and the last element is another tuple. Please see my example below. The original list will have the same length inside all the tuples.
For example:
list1=[('This','Is', 'The', 'First', 'List'),('This','Is', 'The', Second', 'List'),('This','Is', 'The', 'Third', 'List')]
new_list =[(('This','Is', 'The', 'First'), 'List'),(('This','Is', 'The', 'Second'), 'List),(('This','Is', 'The', 'Third'), 'List')]
Need a dynamic way to check the length each element in the list and then create the new list in the form of
[(element1, element2, elementn), lastelement)]
The list can be of n length. Therefore, need to check the length and loop through the list.
Another example:
list2=[('This','Is', 'The', 'First'),('This','Is', 'The', Second'),('This','Is', 'The', 'Third')]
new_list =[(('This','Is', 'The'), 'First'),(('This','Is', 'The'), 'Second'),(('This','Is', 'The), 'Third')]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!