Every day I love python more and more.
Today, I was writing some code like:
for i in xrange(N):
do_something()
I had to do som
Use the _ variable, as I learned when I asked this question, for example:
# A long way to do integer exponentiation
num = 2
power = 3
product = 1
for _ in xrange(power):
product *= num
print product
I just use for _ in range(n), it's straight to the point. It's going to generate the entire list for huge numbers in Python 2, but if you're using Python 3 it's not a problem.