- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

When it is required to find the redundancy rates for every row of a matrix, a simple iteration and the ‘append’ method can be used.

Below is a demonstration of the same

my_list = [[91, 52, 12, 29, 33], [54, 54, 54, 54, 54], [11, 22, 33, 59, 95]] print("The list is :") print(my_list) my_result = [] for sub in my_list: my_result.append(1 - len(set(sub)) / len(sub)) print("The result is :") print(my_result)

The list is : [[91, 52, 12, 29, 33], [54, 54, 54, 54, 54], [11, 22, 33, 59, 95]] The result is : [0, 1, 0]

A list of list is defined and is displayed on the console.

An empty list is created.

The original list is iterated over, and when a condition is met, it is appended to the empty list.

This is displayed as the output on the console.

- Related Questions & Answers
- C++ program to find the Sum of each Row and each Column of a Matrix
- How to find the row products for each row in an R matrix?
- Program to find smallest intersecting element of each row in a matrix in Python
- Find the column index of least value for each row of an R matrix
- How to find the row sum for each column by row name in an R matrix?
- How to find the row means for each matrix stored in an R list?
- Find maximum element of each row in a matrix in C++
- Find the column number with largest value for each row in an R matrix.
- Python Program to find the transpose of a matrix
- Python Program to convert a list into matrix with size of each row increasing by a number
- Python Program to Cyclic Redundancy Check
- How to find the index of n number of maximums in each row of a matrix in R?
- How to find the maximum value for each column of a matrix in R?
- How to find the row products for each row in an R data frame?
- Find the transpose of a matrix in Python Program

Advertisements