Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:10:30+00:00 2026-06-16T11:10:30+00:00

I need some help on my code below,I have the sample input and expected

  • 0

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()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:10:35+00:00Added an answer on June 16, 2026 at 11:10 am

    You can turn the numrefs list into a dict called numrefs_index using a comprehension. That way you can use the in operator and access the references more quickly.

    def p4(base_num):
        numrefs = ['nums/89/202089/4', 'nums/39/205739/2', 'nums/94/203455/6']
        num_ignore = [150362, 147117]
        numrefs_index = dict((int(x.split('/')[2]), x) for x in numrefs)
        for line in file("num_ids.txt"):
            num = int(line)
            if num > base_num and num not in num_ignore and num in numrefs_index:
                print numrefs_index[num]
    
    if __name__ == "__main__":
        p4(203456)
    
    # prints:
    # nums/39/205739/2
    

    The numrefs_index line builds this dict:

    {202089: 'nums/89/202089/4',
     203455: 'nums/94/203455/6',
     205739: 'nums/39/205739/2'}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am not that skilled at Excel/VBA and need some help. The code below (in
I need your help with some sample code for a situation I could not
Need some regular expressions help. So far I have my code working to allow
I need your help in JAVA (with some sample code if possible) regarding to
I need some help with floating point numbers...please! Here's the thing, I have code
I need some help in terms of profiling existing code in terms of execution
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need some help with some PHP and MySQL code. At the moment I
Hey all i am in need of some help getting my code working correctly
I got some code off the Internet and now I just need help to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.