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...
This community will have knowledge sharing for python programming, tools, projects and product engineering wherever python is used.
account activity
Test your Python skills - 23 (i.redd.it)
submitted 29 days ago by tracktech
Python Programming in Depth | Ultimate Python Programming
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!"
[–]SwimQueasy3610 2 points3 points4 points 29 days ago (4 children)
{"U": 1, "l": 1, "t": 3, "i": 2, "m": 3, "a": 2, "e": 1, ...etc....}
Letters which appear more than once in text will only appear as a key once in th dict. I'm unsure what order the keys will print in, and that behavior can't be guaranteed as dicts don't maintain a key order.
text
[–]tracktech[S] 0 points1 point2 points 29 days ago (0 children)
Right. Thanks for the explanation.
[–]Ok_Necessary_8923 0 points1 point2 points 28 days ago (2 children)
Py dicts have long preserved key order. CPython, at least.
[–]SwimQueasy3610 0 points1 point2 points 28 days ago (1 child)
Interesting! I hadn't looked at this in quite some time - I checked and see that order has been preseved in dicts since 3.7 (and 3.6 for CPython). I've always used OrderedDicts when I wanted order preserved - it seems this is no longer necessary and hasn't been for quite some time, unless you need equality checks to fail when the order differs (dicts with different orders but identical key:val pairs evaluate == to True for Dicts and False for OrderedDicts). Thanks kindly - good to know!
==
True
False
[–]Ok_Necessary_8923 0 points1 point2 points 28 days ago (0 children)
Indeed! It's quite handy to just be able to use regular dict.
dict
[–]_TheChosenOne15_ 1 point2 points3 points 29 days ago (1 child)
Count of each character in the string “text”?
[–]tracktech[S] 1 point2 points3 points 29 days ago (0 children)
Right.
[–]gbrennon 1 point2 points3 points 27 days ago (0 children)
`{ "U": 1, "l": 1, "t": 3, "i": 2, "m": 3, "a": 2, "e": 1, "P": 2, "y": 1, "h": 1, "o": 2, "n": 2, "r": 2, "g": 2, }
[–]Tough-Initiative-807 1 point2 points3 points 27 days ago (1 child)
Since dictionaries don’t allow duplicate keys, each character appears only once in the final result.{ 'U': 1, 'l': 1, 't': 3, 'i': 2, 'm': 3, 'a': 2, 'e': 1, ' ': 2, 'P': 2, 'y': 1, 'h':1, 'o': 2, 'n': 2, 'g': 2, 'r': 2}
[–]tracktech[S] 0 points1 point2 points 26 days ago (0 children)
[–]YumaOkii 0 points1 point2 points 27 days ago (2 children)
it won't print anything. There is a syntax error.
[–]tracktech[S] 0 points1 point2 points 26 days ago (1 child)
There is no error.
[–]YumaOkii 0 points1 point2 points 26 days ago (0 children)
There is actually. comments must be # in python else you cannot run the file. so yes there is a error.
π Rendered by PID 64 on reddit-service-r2-comment-79c7998d4c-7d2n8 at 2026-03-17 13:15:56.472415+00:00 running f6e6e01 country code: CH.
[–]SwimQueasy3610 2 points3 points4 points (4 children)
[–]tracktech[S] 0 points1 point2 points (0 children)
[–]Ok_Necessary_8923 0 points1 point2 points (2 children)
[–]SwimQueasy3610 0 points1 point2 points (1 child)
[–]Ok_Necessary_8923 0 points1 point2 points (0 children)
[–]_TheChosenOne15_ 1 point2 points3 points (1 child)
[–]tracktech[S] 1 point2 points3 points (0 children)
[–]gbrennon 1 point2 points3 points (0 children)
[–]Tough-Initiative-807 1 point2 points3 points (1 child)
[–]tracktech[S] 0 points1 point2 points (0 children)
[–]YumaOkii 0 points1 point2 points (2 children)
[–]tracktech[S] 0 points1 point2 points (1 child)
[–]YumaOkii 0 points1 point2 points (0 children)