Given a Matrix, the task is to write a Python program to extract rows with no repeated data types.
Input : test_list = [[4, 3, 1], ["gfg", 3, {4:2}], [3, 1, "jkl"], [9, (2, 3)]]
Output : [['gfg', 3, {4: 2}], [9, (2, 3)]]
Explanation : [4, 3, 1] are all integers hence omitted. [9, (2, 3)] has integer and tuple, different data types, hence included in results.
Input : test_list = [[4, 3, 1], ["gfg", 3, {4:2}, 4], [3, 1, "jkl"], [9, (2, 3)]]
Output : [[9, (2, 3)]]
Explanation : [4, 3, 1] are all integers hence omitted. [9, (2, 3)] has integer and tuple, different data types, hence included in results.
In this, we use type() to check for data types of each element of rows, and if the data type repeats, the row is not included in the result.
OutputThe original list is : [[4, 3, 1], ['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
The Distinct data type rows : [['gfg', 3, {4: 2}], [9, (2, 3)]]
OutputThe original list is : [[4, 3, 1], ['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
The Distinct data type rows : [['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
OutputThe original list is : [[4, 3, 1], ['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
The Distinct data type rows : [['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
OutputThe original list is : [[4, 3, 1], ['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
The Distinct data type rows : [['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
OutputThe original list is : [[4, 3, 1], ['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]
The Distinct data type rows : [['gfg', 3, {4: 2}], [3, 1, 'jkl'], [9, (2, 3)]]