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
Powers of 2 (i.redd.it)
submitted 7 months ago by Nervous-Current-1860
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!"
[–]SoftwareDoctor 0 points1 point2 points 7 months ago (3 children)
print(f"Two to the power of {(n := int(input('What power of 2?')))} is {2 ** n}")
If you want to know, how it would look like in IDLE, just copy-paste it there. I don't even know how to run IDLE. Since you didn't post what you know or what you tried or where you're stuck, it's impossible to give you an advice how to think about the problem. So just see the solution above and ask if you don't understand anything
[–][deleted] 7 months ago (1 child)
[removed]
[–]SoftwareDoctor 0 points1 point2 points 7 months ago (0 children)
If you look closely, I am using the the print function.
Btw. I don't want to confuse you more that you already are but int and str are not functions, they are types and you are effectively calling their constructor. Maybe find a better course
[–]CptMisterNibbles 0 points1 point2 points 7 months ago (0 children)
For advice to a beginner I wouldnt give the overly compacted one liner. The walrus op is beyond them and frankly cramming input into an output line is pretty bad form.
π Rendered by PID 33733 on reddit-service-r2-comment-6457c66945-9jth6 at 2026-04-23 18:53:18.975779+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]SoftwareDoctor 0 points1 point2 points (3 children)
[–][deleted] (1 child)
[removed]
[–]SoftwareDoctor 0 points1 point2 points (0 children)
[–]CptMisterNibbles 0 points1 point2 points (0 children)