I am new to python and I was wondering if there is a way of using python to automatically make n
files, define each file as n.txt
and then write n**2
into each file.
I have tried to think through this problem and came up with the following suggestion:
for i in range (0,100,1):
x = open ("i%.txt", "w+") %(i)
x.write (i**2)
However, it returns the error:
TypeError: unsupported operand type(s) for %: '_io.TextIOWrapper' and 'int'
.