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 51 times
0

Martin Hallén
- 1,492
- 1
- 12
- 27

jath03
- 2,029
- 2
- 14
- 20
-
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
- 994
- 2
- 15
- 38
-
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
-