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?
CodePudding user response:
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')]