About 371,000 results
Open links in new tab
  1. Converting a string into a list in Python - Stack Overflow

    Mar 30, 2010 · Your question admits of too many possibilities. Does the text file only contain a list of numbers, or is that list in a larger context. Do you get to control how you read from the document or are you stuck with having read a string that contains a bunch of newline or whitespace separated numbers?

  2. How can I turn a string into a list in Python? - Stack Overflow

    Strings in Python behave like lists of characters. E.g. 'hello'[1] -> 'e'. Are you sure you need a list?

  3. How to convert comma-delimited string to list in Python?

    Oct 21, 2011 · python parsing list tuples edited Oct 10, 2012 at 16:30 FreeAsInGimme 737 asked Oct 21, 2011 at 1:33 O.rka 30.8k78213335 Related Convert string representation of list to list in Python – Bhargav Rao CommentedJun 22, 2016 at 10:29 7 Answers Sorted by: 451

  4. python - How to convert string representation of list to a list

    The json module is a better solution whenever there is a stringified list of dictionaries. The json.loads (your_data) function can be used to convert it to a list.

  5. python - How do I split a string into a list of words? - Stack Overflow

    To split on other delimiters, see Split a string by a delimiter in python. To split into individual characters, see How do I split a string into a list of characters?.

  6. String to list in Python - Stack Overflow

    Off-topic, but for search's sake : Convert string representation of list to list.

  7. python - Convert a space delimited string to list - Stack Overflow

    Jul 30, 2019 · i have a string like this : states = "Alaska Alabama Arkansas American Samoa Arizona California Colorado" and I want to split it into a list like this states = {Alaska, Alabama, Arkansas, American, Samoa, ....} I am new in python. Help me, please. :-)) edit: I need to make a random choice from states and make it like the variable.

  8. python - How to convert list to string - Stack Overflow

    Apr 11, 2011 · str (anything) will convert any python object into its string representation. Similar to the output you get if you do print (anything), but as a string. – ToolmakerSteve CommentedJan 27, 2016 at 20:17 4

  9. python - How do I split a string into a list of characters? - Stack ...

    Jul 3, 2022 · list builds a new list using items obtained by iterating over the input iterable. A string is an iterable -- iterating over it yields a single character at each iteration step.

  10. python - Converting a String to a List of Words? - Stack Overflow

    May 31, 2011 · I'm trying to convert a string to a list of words using python. I want to take something like the following: string = 'This is a string, with words!' Then convert to something like this : list = ...

Refresh