Reputation: 105
Here is my code so far.
def pfunc():
portList = []
user_choice_port = userPort.get()
portList.append(user_choice_port)
the userPort
is basically a text variable for what the user will enter into an entry box (which will be ports). The user will enter the port numbers like this:
23, 80, 44, etc.
How do I take those numbers and put them into a list. Cause whenever I do it puts them in as a string that looks like this:
['23, 80, 44']
When I want it to look like this:
[23,80,44]
I cannot figure this out so any help would be appreciated
Upvotes: 0
Views: 209
Reputation: 663
This should help.
user_choice_port = "23, 80, 44"
print map(int, user_choice_port.split(","))
print [int(n) for n in user_choice_port.split(",")]
Upvotes: 1