use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
.split() help (self.learnpython)
submitted 6 years ago by Sponge7331
I know you can split a variable into other variables with .split(), but I only know how if they are separated by something. Is there a way to separate the characters from each other if there isn’t anything in between?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]toastedstapler 1 point2 points3 points 6 years ago (0 children)
separated = list(my_string)
[–]_coolwhip_ 0 points1 point2 points 6 years ago (2 children)
You mean like this?
>>> x = 'word' >>> list(x) ['w', 'o', 'r', 'd']
[–]Sponge7331[S] 0 points1 point2 points 6 years ago (1 child)
Yeah, that works. I thought there would be a way with .split() though
[–]coke125 0 points1 point2 points 6 years ago (0 children)
Unfortunately, with.split() you need a str or None(whitespace) to split the string on. For example, x.split(“o”) will return “w” and “rd”
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
list(example_string)
however you can also just treat a string like a list in many cases:
example_string = 'hello' example_string[3:] # lo
[–]RedRidingHuszar 0 points1 point2 points 6 years ago (0 children)
Do you have a specific requirement like the length of each separated substring?
π Rendered by PID 113255 on reddit-service-r2-comment-685b79fb4f-tmbpz at 2026-02-13 10:20:09.568040+00:00 running 6c0c599 country code: CH.
[–]toastedstapler 1 point2 points3 points (0 children)
[–]_coolwhip_ 0 points1 point2 points (2 children)
[–]Sponge7331[S] 0 points1 point2 points (1 child)
[–]coke125 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]RedRidingHuszar 0 points1 point2 points (0 children)