Python Forum
Displaying list correspond to the column number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying list correspond to the column number
#10
(Apr-04-2021, 10:02 AM)danlopek14q Wrote:
def func(arr, col = None):
    if col == None: return ''
    return [arr[i] for i in col]

arr = ['Mars', 'Hot', 22, True]
column = [0, 1]
print(func(arr, column))
Output:
['Mars', 'Hot']
Reply


Messages In This Thread
RE: Displaying list correspond to the column number - by naughtyCat - Aug-27-2021, 04:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  list digit into number Voldyy 2 1,558 Jul-10-2022, 06:13 PM
Last Post: deanhystad
  How to convert every even number in a list to odd? Bruizeh 4 3,795 Aug-27-2021, 03:04 AM
Last Post: naughtyCat
  Get the biggest number from a two dimensional list rs74 13 4,096 Aug-09-2020, 04:02 PM
Last Post: deanhystad
  How can I print the number of unique elements in a list? AnOddGirl 5 3,309 Mar-24-2020, 05:47 AM
Last Post: AnOddGirl
  Multiplying number in a list in an order pythoneer 12 6,663 Mar-23-2018, 08:21 PM
Last Post: buran
  Displaying number of currency danellapotter 3 2,786 Jan-16-2018, 07:58 PM
Last Post: buran
  adding a number to the list atux_null 4 3,897 Nov-06-2017, 07:01 PM
Last Post: gruntfutuk
  Displaying a long list with Rows and Columns ngr33n 5 11,049 Sep-21-2017, 10:17 PM
Last Post: ngr33n
  sorted list not displaying Crackity 6 5,117 Jul-18-2017, 12:50 PM
Last Post: sparkz_alot
  Determine if a list contains a specific number of an item flannel_man 3 4,945 Nov-12-2016, 04:46 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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