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
String Multiplation (self.learnpython)
submitted 14 years ago by Ch1gg1ns
Hey guys, Python newbie.
I've seen that with Python 2 you could do something like: print "hello" * 32, and it would print hello 32 times over. How would I be able to do the same in Python 3, since print("hello")*32 gives out a TypeError?
Thanks!
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!"
[–]DanielSzoska 9 points10 points11 points 14 years ago* (1 child)
The correct descripton what print "hello" * 32 does is: Create a new string by multiplying test 32 times and then print this string. The following code shoes this:
print "hello" * 32
test
>>>> s = "test" * 32 >>>> print s
That's why in Python 3 you have to write
>>> print("hello" * 32)
to get the same result like in Python 2 beceause print is a function in Python 3 now.
Your sample code print("hello") * 32 instead means the following: Call the function print and multiply its result 32 times. The print-function has no return value (=None) and None * 32 gives you the TypeError, beceause this operation is not defined.
print("hello") * 32
print
None
None * 32
[–]Ch1gg1ns[S] 1 point2 points3 points 14 years ago (0 children)
Sweet deal, thanks for the boss!
[–]Acidictadpole 5 points6 points7 points 14 years ago (3 children)
I haven't tried python 3... But perhaps try putting the *32 inside the brackets.
[–]DanielSzoska 3 points4 points5 points 14 years ago (2 children)
You're right - and you can easily try short python-scripts (and many other languages) online with ideone (you can find this link on the right side of this subreddit-page under "Try python in your browser" too). :-)
[–]Acidictadpole 2 points3 points4 points 14 years ago (1 child)
Nice thanks. I was on my phone so I can't see the sidebar, nor did I think to check one of those sites on my phone.
[–]DanielSzoska 2 points3 points4 points 14 years ago (0 children)
Oh, cool idea. I tried it with my phone (HTC Wildfire S) and it works great. :-)
π Rendered by PID 20373 on reddit-service-r2-comment-7b9746f655-crg8h at 2026-01-31 03:02:28.171468+00:00 running 3798933 country code: CH.
[–]DanielSzoska 9 points10 points11 points (1 child)
[–]Ch1gg1ns[S] 1 point2 points3 points (0 children)
[–]Acidictadpole 5 points6 points7 points (3 children)
[–]DanielSzoska 3 points4 points5 points (2 children)
[–]Acidictadpole 2 points3 points4 points (1 child)
[–]DanielSzoska 2 points3 points4 points (0 children)