2021年1月25日星期一

Multiple lines of data, want to get an index or figure out how to get it in order

  1. reads and stores the data in this file.
  2. User for two integers corresponding to start and end years, and finds and lists the year of publication, title, author, in that order, of all books published during that period.
  3. It repeats the previous step till the user enters -1 when prompted for the start year.

This is what I have so far (see picture)

def main():       file = open("resources.txt","r")       myList = []       year1 = int(input("Enter the first year:"))       year2 = int(input("Enter the second year: "))       for x in range(year1, year2):           print(yearofpublication,title, author)        

and the file is 1000 lines

I need help with #2 mainly. Thank you

enter image description here

https://stackoverflow.com/questions/65895393/multiple-lines-of-data-want-to-get-an-index-or-figure-out-how-to-get-it-in-orde January 26, 2021 at 11:11AM

没有评论:

发表评论