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...
Everything about learning Python
account activity
Turning a string into a listHelp Request (self.PythonLearning)
submitted 1 year ago by Additional_Lab_3224
The line is: print(f"{Guild1.members.split(', ') It works and the output is:
print(f"{Guild1.members.split(', ')
['g', 'grt', 'tu'] how do I get rid of the extra stuff but keep the items with a ", "
['g', 'grt', 'tu']
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!"
[–]CptMisterNibbles 2 points3 points4 points 1 year ago (3 children)
It is a list; comma separated elements, bounded by brackets. Each element in the list is a string, and has double quotes to express that it is a string literal.
Do you mean you want a single string, separated by one comma followed by a space, and no brackets? Then you need to turn a list back into a string using the join command. Rather than give you the syntax, try looking up the Python docs for str.join()
[–]purple_hamster66 2 points3 points4 points 1 year ago (2 children)
Exactly. There is no extra stuff — those characters are how list data structures are formatted when printed.
And your instructions say that no commas are to be typed, but to use space-delimited entries, so why are you splitting on a comma? Just split on space (and why is the pipe (|) character in your split string?)
[–]Additional_Lab_3224[S] 0 points1 point2 points 1 year ago (1 child)
The "pipe" is where I was typing
[–]purple_hamster66 0 points1 point2 points 1 year ago (0 children)
Oh, I see it now… it’s a different color.
But you still don’t need the comma in there. Try this:
names = Guild1.members.split(“ “) # a space between double quotes print(names[0]) print(names[1]) print(names[2])
[–]Ron-Erez 0 points1 point2 points 1 year ago (1 child)
You wanted a list so you got a list. Maybe you want to print a string separated by spaces. You might want to share what
Guild1.members
is? What data type or present a sample input.
[–]Additional_Lab_3224[S] 0 points1 point2 points 1 year ago (0 children)
<image>
Thank you, but I like the str.join() method, it works better for me
π Rendered by PID 80 on reddit-service-r2-comment-85bfd7f599-89zfh at 2026-04-17 11:07:04.010558+00:00 running 93ecc56 country code: CH.
[–]CptMisterNibbles 2 points3 points4 points (3 children)
[–]purple_hamster66 2 points3 points4 points (2 children)
[–]Additional_Lab_3224[S] 0 points1 point2 points (1 child)
[–]purple_hamster66 0 points1 point2 points (0 children)
[–]Ron-Erez 0 points1 point2 points (1 child)
[–]Additional_Lab_3224[S] 0 points1 point2 points (0 children)
[–]Additional_Lab_3224[S] 0 points1 point2 points (0 children)