I need some help on my code below,I have the sample input and expected output,currenlty its not printing anything..please provide your inputs,
Basically my code is parsing the values in num_ids.txt and checking if each value is greater than the base_num value provided and also if the value is not in “num_ignore” list and then(after first 2 conditions are met) it tries to match numrefs list and prints the matched value in numrefs…
EXPECTEDOUTPUT:-
nums/39/205739/2
import os
import subprocess
def p4 (base_num):
numrefs = ['nums/89/202089/4', 'nums/39/205739/2', 'nums/94/203455/6']
num_ignore = [150362, 147117]
'''
num_ids.txt
202089
205739
147117
203455
'''
with open('./num_ids.txt', 'rb') as f:
# Iterate over the file itself
for line in f:
num = int(line)
if num > base_num and num not in num_ignore and line in numrefs:
print numrefs
def main():
base_num=203456
p4(base_num)
if __name__ == '__main__':
main()
You can turn the
numrefslist into a dict callednumrefs_indexusing a comprehension. That way you can use theinoperator and access the references more quickly.The
numrefs_indexline builds this dict: