For example if my text file is:
blue green yellow black
Here there are four lines and now I want to get the result as four. How can I do th
Use:
num_lines = sum(1 for line in open('data.txt')) print(num_lines)
That will work.