Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print multiple record lines
#1
I am creating a simple program that looks up the name of a job and prints out the full job name and number.

I want to be able to put in partial string and have the program print any job name that has that string.

ie. user enters "short"
program prints "Short North Phase 3 - 2016-0401"
"Short North Phase 2 - 2016-0405"
"Short North Public Outreach - 2016-0551"

I am stuck on the printing multiple lines that match the input string.
here is my current code:

while True:
    jobname=input("Please enter job name")
    jobname=jobname.upper()



    jobs = open("jobs.txt")
    for line in jobs:
        record = line.split('|')
        if jobname in record[0]:
            found = True
            break
        else:
            found = False
            continue

    if found == False:
        print("Job name not found")
    else:
        print(record[0], record[1])
any help would be greatly appreciated.
Reply


Messages In This Thread
Print multiple record lines - by ntigner - Feb-08-2018, 04:15 PM
RE: Print multiple record lines - by nilamo - Feb-08-2018, 04:27 PM
RE: Print multiple record lines - by ntigner - Feb-08-2018, 04:36 PM
RE: Print multiple record lines - by nilamo - Feb-08-2018, 05:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Last record in file doesn't write to newline gonksoup 3 473 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  How do I stream and record at the same time with arducam? traderjoe 0 485 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  How to write the condition for deleting multiple lines? Lky 3 1,177 Jul-10-2022, 02:28 PM
Last Post: Lky
  Delete multiple lines from txt file Lky 6 2,346 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  failing to print not matched lines from second file tester_V 14 6,183 Apr-05-2022, 11:56 AM
Last Post: codinglearner
  Display table field on multiple lines, 'wordwrap' 3python 0 1,793 Aug-06-2021, 08:17 PM
Last Post: 3python
  pulling multiple lines from a txt IceJJFish69 3 2,608 Apr-26-2021, 05:56 PM
Last Post: snippsat
  why print('\n') produced 2 new lines instead of 1 - Located inside a FOR loop JulyFire 2 2,556 Jan-10-2021, 01:50 AM
Last Post: JulyFire
Question How to print multiple elements from multiple lists in a FOR loop? Gilush 6 2,989 Dec-02-2020, 07:50 AM
Last Post: Gilush
  How to print string multiple times on new line ace19887 7 5,817 Sep-30-2020, 02:53 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020