Length of the line in a file in Python returns value always as No. of Characters + 1
Question: I am using python 2.7.x  
I have a file page06.txt

    
    
    1
    22
    333
    4444
    55555
    666666
    7777777
    88888888
    

I am reading this file through a program:

    
    
    from __future__ import print_function
    fileobj = open("page06.txt")
    i = 0
    while True:
        F = fileobj.readline()
        print("::::", len(F))
        if len(F) <= 0:
            break;
        print(F , end="")
    fileobj.close()
    

The first line contains 1, so as per my understanding is that len(F) must
return 1 but it returns 2. So, whyis the length of all the lines in the file
always is

    
    
    "No. of characters" +1
    


Answer: You counted also the new line. Use `F = fileobj.readline().strip()` to get the
line without the new line character.

