Python Forum
Extract columns from a 2 dimentional table
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extract columns from a 2 dimentional table
#5
(Feb-22-2022, 06:56 PM)BashBedlam Wrote: One reason for not using one and two letter variable names is that things likematcan be confusing. Descriptive variable names make the code much clearer and easier to work with and understand.
M = [[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]]

def column (matrix, column_number) :
	output_column = []
	for row in matrix :
		output_column.append (row [column_number])
	return output_column

duly noted, thank you !

print (column (M, 1))
Reply


Messages In This Thread
RE: Extract columns from a 2 dimentional table - by Leyo - Feb-22-2022, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Table with fixed columns Mike2607 3 2,926 Nov-26-2019, 08:17 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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