I have written the code for the following problem. the code is working fine but i am not able to remove the space after the end of each row. can someone please help? An Upper triangular matrix is a square matrix (where the number of rows and columns are equal) where all the elements below the diagonal are zero. For example, the following is an upper triangular matrix with the number of rows and columns equal to 3. 1 2 3 0 5 6 0 0 9 Write a program to convert a square matrix into an upper triangular matrix. Input Format: The first line of the input contains an integer number n which represents the number of rows and the number of columns. From the second line, take n lines input with each line containing n integer elements. Elements are separated by space. Output format: Print the elements of the matrix with each row in a new line and each element separated by a space. Example 1: Input: 3 1 2 3 4 5 6 7 8 9 Output: 1 2 3 0 5 6 0 0 9 https://code.sololearn.com/cqRGGLYJOD1
3/21/2019 3:18:27 PMNilutpol Kashyap
5 AnswersNew Answer
hi, if you don’t want this: 1 2 3 4 5 6 7 8 9 but it should look like this: 123 456 789 you have to change the print statment: for i in range(n): for j in range(n): print(m[i][j], end= "") if i<n-1: print() Remove the blanc in end=“ “ to: end=“”
Brent Meeusen I know that. I am facing some problems in my assignments. I wrote the code but I am facing some problems. I just wanted some help.
This is for your feed, not for the QA which is purely for programming-related problems, not for challenges :)
Lothar hi thanx for your help. but I want the spaces between the elements but no spaces after 3, 6, 9. I am not able to figure that out. thanx
Hello. Thanks everyone but I have resolved my problem. Thanx a lot. https://code.sololearn.com/c3jNkDvS7FK8/?ref=app