number of lines in a file python readlines() code example Example: python read lines f = open("filename") lines = f.readlines()