Python Forum
list comprehension : print column as row
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list comprehension : print column as row
#1
I have a 9 x 6 matrix (each value is a string) and need to print columns as rows, which is 6 x 9 matrix.

So, when I execute the following code it just prints the same without the strings.
No matter what I try, it's just does not work.

Here is the code : so when I just print row[0], it prints the row as column, but it doesn't work using the nested for loop

for row in grid:
    # print(row[0], end=" ")
    for col in row:
        print(col, end=" ")
    print()
Any thoughts and ideas, please ?
Reply


Messages In This Thread
list comprehension : print column as row - by pyseeker - Aug-22-2019, 06:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List Comprehension Issue johnywhy 5 575 Jan-14-2024, 07:58 AM
Last Post: Pedroski55
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 509 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  How do you get Python to print just one value in a list? 357mag 3 1,045 May-17-2023, 09:52 PM
Last Post: rob101
  Using list comprehension with 'yield' in function tester_V 5 1,316 Apr-02-2023, 06:31 PM
Last Post: tester_V
  list comprehension 3lnyn0 4 1,464 Jul-12-2022, 09:49 AM
Last Post: DeaD_EyE
  Print List to Terminal DaveG 2 1,462 Apr-02-2022, 11:25 AM
Last Post: perfringo
  Not able to add extra column to the list in the python shantanu97 2 1,676 Nov-17-2021, 10:14 AM
Last Post: snippsat
  List comprehension used differently coder_sw99 3 1,757 Oct-03-2021, 04:12 PM
Last Post: coder_sw99
  How to invoke a function with return statement in list comprehension? maiya 4 2,913 Jul-17-2021, 04:30 PM
Last Post: maiya
  List comprehension and Lambda cametan 2 2,276 Jun-08-2021, 08:29 AM
Last Post: cametan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020