Simple questions but it's annoying me. I'm attempting to loop over a series of products of varying factors and then print each product to a file. I can get the code to work using the "with" statement but can't get it to work without it and I can't understand why. I am opening the file and then closing it as usual. Code is as follows:
f = open('out.txt', 'w')
for num1 in range(100,999):
for num2 in range(100,999):
product=num1*num2
length=len(str(product))
if length % 2 == 0:
#halfway_point=
print >> f, product
f.close()
It is failing on the last line with:
SyntaxError: invalid syntax
print >> f, product?