0
Python files
Find all four-digit positive integers with by the following property: a number composed of output two digits divided by a number composed of last two digits. Write results to file numbers.txt, one number per line. https://code.sololearn.com/ccjpM6C2dR2h/?ref=app
3 Respostas
+ 2
b != 0 should be checked first.
also there should not be indentation before f.close()
f=open('number.txt', 'w')
for i in range(1000,10000):
a=i//100
b=i%100
if b!= 0 and a%b==0:
print(i)
f.write(str(i) + '\n')
f.close()
+ 1
Thanks