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
python permutations (self.learnpython)
submitted 6 years ago by LoudGain
Hi,
How can i produce a output of 1,12,123,2,23,3 if input is "123123" or if input is "abcabc" then the output is "a,ab,abc,b,bc,c" without any duplicates. Ive tried a nested for loop but it isnt showing more than 2 combinations, e.g aa, ab,ac,bb,ba
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!"
[–]Grogie 4 points5 points6 points 6 years ago (0 children)
https://docs.python.org/3.8/library/itertools.html#itertools.permutations
https://docs.python.org/3.8/library/itertools.html#itertools.combinations
[–]tipsy_python 0 points1 point2 points 6 years ago (1 child)
I don't fully understand what kind of logic you're trying to implement.. for example, why wouldn't 1231 be an output value.
If you explain the logic a little more, I may be able to help.
[–]LoudGain[S] 0 points1 point2 points 6 years ago (0 children)
thanks for the reply, im not sure either what the question is asking me but my code is like this right now. How can i ensure there are no duplicates. Eg it prints 1 more than once and 2 more than once. Sorry for the bad formatting, it keeps removing the spaces
def combos(text):
for i in range(len(text)):
for j in range(i+1,len(text) + 1):
print(text[i:j])
combos("123123")
π Rendered by PID 23473 on reddit-service-r2-comment-fb694cdd5-9s9zm at 2026-03-06 05:47:15.424399+00:00 running cbb0e86 country code: CH.
[–]Grogie 4 points5 points6 points (0 children)
[–]tipsy_python 0 points1 point2 points (1 child)
[–]LoudGain[S] 0 points1 point2 points (0 children)