Issue
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?
Solution
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')]
Answered By - rebahozkoc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.