I am trying to convert a string such as '239,24,6462,93' to a list like ['239', '24', '6462', '93'] as sort of an opposite of str.join() .
Is there anything that can do that?
All help appreciated.
Asked
Active
Viewed 50 times
0
Martin Hallén
- 1,444
- 1
- 12
- 26
jath03
- 1,499
- 2
- 14
- 19
-
Welcome to Stackoverflow :-) Please look at [ask], this will help to get useful answers – JimHawkins Jun 19 '16 at 17:25
2 Answers
1
Lets say this string is called "str".
str='239,24,6462,93';
Now to get these numbers into a list you can type the following:
numbers=str.split(",")
Output
['239', '24', '6462', '93']
cssGEEK
- 974
- 2
- 14
- 36
-
Why are you using the word list in this example? I thought you should never use the names of Python built-ins as variable names. – PyNEwbie Jun 19 '16 at 19:38
-