as path prepend
as path prepend

Reputation: 47

Change len of a list

I have a list as below

['1024-65535/tcp', '1024-65535/udp']

I would like to change the len of the list from 2 to one and get some

[('1024-65535/tcp', '1024-65535/udp')] so len 1. I tried resize and also join but they do something else (resizie is cutting out element of list, join give me back a list with len as number of chars that i join). Any suggestion?

Upvotes: 0

Views: 288

Answers (1)

rebahozkoc
rebahozkoc

Reputation: 158

You can create a new list and then turn it to a tuple. After that you can make that tuple again a list.

myList = ['1024-65535/tcp', '1024-65535/udp']
newList = [tuple(myList)]
# newList is equal to [('1024-65535/tcp', '1024-65535/udp')]

Upvotes: 1

Related Questions