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

17th Mar 2020, 1:38 PM
Влад Голованов
Влад Голованов - avatar
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()
17th Mar 2020, 2:44 PM
andriy kan
andriy kan - avatar
+ 1
Thanks
17th Mar 2020, 2:45 PM
Влад Голованов
Влад Голованов - avatar
17th Mar 2020, 1:55 PM
Влад Голованов
Влад Голованов - avatar