Iterate a certain number of times without storing the iteration number anywhere

Viewed 165787

I was wondering if it is possible to perform a certain number of operations without storing the loop iteration number anywhere.

For instance, let's say I want to print two "hello" messages to the console. Right now I know I can do:

for i in range(2):
    print "hello"

but then the i variable is going to take the values 0 and 1 (which I don't really need). Is there a way to achieve the same thing without storing those unwanted values anywhere?

Needless to say, using a variable is not a big deal at all... I'm just curious.

9 Answers
Related