Hi,
I am new to using python. I have a problem. I need to read in strings from a data file and only count those that are explicitly numbers. So I am using the isdigit() method.
But the problem is that the data file has multiple strings so the problem is the \n messes my code up.
My program only works on the last number because that is the end of the file and there are no more empty spaces or a return at the end of file. So it only counts the last number as being a number.
Is there anyway to ignore \n when reading in strings or does readline() and isdigit() automatically ignore this \n?
Thanks!
I am new to using python. I have a problem. I need to read in strings from a data file and only count those that are explicitly numbers. So I am using the isdigit() method.
But the problem is that the data file has multiple strings so the problem is the \n messes my code up.
My program only works on the last number because that is the end of the file and there are no more empty spaces or a return at the end of file. So it only counts the last number as being a number.
Is there anyway to ignore \n when reading in strings or does readline() and isdigit() automatically ignore this \n?
Thanks!
Comment