This is my code

index_dictionary = dict()

with open("BIBLE.txt") as Bible:
    count = 0
    for line in Bible:
        index = line[:8].split()
        Book = index[0].strip().upper()
        chapter, verse = list(map(str.strip, index[1].split(":")))
        index_dictionary[(Book, chapter, verse)] = count
        count += len(line)

Bible = open("BIBLE.txt")
while True:
    search_engine = input(
                          "Book list: Ge(Genesis), Ex(Exodus), Le(Leviticus), Nu(Number), De(Deuteronomy), "
                          "Jos(Joshua) \n "
                          "jg(Judges)"
                          "(or x to exit)      \n"
                          "Input Book(Abbreviation only!):Chapter:verse     \n "

    )

    if search_engine == "x":
        print("see you next time")
        break
    Book, chapter, verse = list(map(str.strip, search_engine.split(":")))
    keyword = (Book.upper(), chapter, verse)
    if keyword in index_dictionary:
        #Bible.seek(index_dictionary)
        bible = Bible.readline()
        print(bible)
Bible.close()

I get reference from this https://www.daniweb.com/programming/software-development/threads/460206/parsing-bible-for-specific-verses

There is a few problem, first, it did not print what I want it too, it only print Ge:1:1 the first time, the second time you print you get Ge:1:2, even if you put Joh:3:16 you will still get Ge:1:1 I dont know anymore. Can someone help me? And If i put Bible.seek(index_dictionary) it will got error code '<' not supported between instances of 'dict' and 'int'

Thanks in advance

  1. What are you wanting as the output from this script?
  2. What does the input (bible.txt) look like?

In this block you are simply reading the next line of the file instead of searching for the desired verse.

    if keyword in index_dictionary:
        #Bible.seek(index_dictionary)
        bible = Bible.readline()
        print(bible)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.