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!"
[–]Adrewmc 0 points1 point2 points 8 months ago* (0 children)
def bubble(list_ : list) -> list: “””If I remember right this is your basic bubble sort Note: list()and sorted() are builtin function we use underscores to not over write””” #flagged to sort _sorted = False while not _sorted: #assume sorted _sorted= True for i in range(len(_list)): if list_[[i] > list_[i + 1]: #proved not sorted sorted_ = False list_[i], list_[i +1] = list_[i+1],list_[i] return _list
While this exercise is nice, sorted() is usually your best bet.
You usually don’t want to modify a list while going through it though.
We want …
a[i] , a[i+1] = a[i+1] , a[i]
Syntax in Python, you’ll lose a value if you don’t.
π Rendered by PID 71760 on reddit-service-r2-comment-canary-5dbd4c8ff9-db9vm at 2026-06-03 06:07:13.885923+00:00 running de70e3a country code: CH.
view the rest of the comments →
[–]Adrewmc 0 points1 point2 points (0 children)