Hi everyone, I am a beginner in python, and I would really appreciate if someone could help me with this.
Basically I am trying to write a program where I will be importing a file that has a lot of numbers in many lines, there are also some blank spaces. Now how do I count the number of items? So far I only got this:
import string
def main():
fname = raw_input ("Enter filename:")
infile = open(fname,"r")
data = infile.read()
items = len(open(fname).readlines())
print items, "number of items."
main()
now the only problem it is also counting the number of blank spaces. How do I make it so it only counts the number of items but not the blank spaces between the items?
note: move from starting python where it violated the rules