dimanche 25 janvier 2015

find missing numbers in series using python


Vote count:

0




I have a file with numbers and I need to find the missing ones.



cat head.txt
7045000000
7045000001
7045000003


As you can see the number 7045000002 is missing. This code is not working:



check=int(7044999999)
with open('head.txt' , 'r') as f:
for line in f:
myl = line[:5]
if myl == '70450':
if int(line) == check+1:
check = int(line)
else:
check = int(line)+1
print check


The numbers should start with 70450 and there the "myl" variable is necessary.



asked 24 secs ago

shantanuo

5,412






find missing numbers in series using python

Aucun commentaire:

Enregistrer un commentaire