# get the filename and open it filename = raw_input("Filename: ") file = open(filename, "r") # initialize the counter total_lines = 0 for line in file: # do the counting total_lines += 1 # summary output print "Total lines:", total_lines