I am having some problems working with the tell method when working with a file. Basically what I am trying to do is use the tell method to find where I currently am within a paragraph and to only display the characters up to a certain tell count. For example:

quote.txt="You will not apply my precept he said shaking his head How often have I said to you that when you have eliminated the impossible whatever remains however improbable must be the truth We know that he did not come through the door the window or the chimney We also know that he could not have been concealed in the room as there is no concealment possible When then did he come The Sign of the Four"

myfile=open("quote.txt","r")
mylist1=[]
myfile.tell()
while myfile.tell() < 50:
    read=myfile.readline()
    print read
    print myfile.tell()
    mylist1.append(read)

I know I could simply put myfile.read(50) and it would display what I needed however I will be using an if statement later to specify and read sections based on the tell.

Any help would be greatly appreciated. I can also provide more information if needed. Thanks again!

What is your problem and what you are trying to do?

I do not undetstand reference to read(50) as it has nothing to do with your code which reads lines.

Line 3 does nothing. Your example input is only one line, so not very good test input for the loop.

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.