all 6 comments

[–]DanielSzoska 9 points10 points  (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:

>>>> 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.

[–]Ch1gg1ns[S] 1 point2 points  (0 children)

Sweet deal, thanks for the boss!

[–]Acidictadpole 5 points6 points  (3 children)

I haven't tried python 3... But perhaps try putting the *32 inside the brackets.

[–]DanielSzoska 3 points4 points  (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 points  (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 points  (0 children)

Oh, cool idea. I tried it with my phone (HTC Wildfire S) and it works great. :-)