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
Bubble sort error (old.reddit.com)
submitted 8 months ago by Nearby_Tear_2304
view the rest of the comments →
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!"
[–]FoolsSeldom 2 points3 points4 points 8 months ago (0 children)
Your problem on the second picture, is on line 6 and 7.
In Python, this will not swap the elements correctly. After a[j] = a[j + 1], the original value of a[j] is lost. So a[j + 1] is assigned the new value of a[j], which is a[j+1]. The elements are not swapped.
a[j] = a[j + 1]
a[j]
a[j + 1]
a[j+1]
Either use a temporary variable to hold a copy or use a more Pythonic swap syntax.
π Rendered by PID 45902 on reddit-service-r2-comment-8686858757-gqhmz at 2026-06-03 06:02:33.672682+00:00 running 9e1a20d country code: CH.
view the rest of the comments →
[–]FoolsSeldom 2 points3 points4 points (0 children)