Mercurial > hg > swc-python-intro
changeset 1:d6b2e34ab8c0
Modified script in order to count number of lines in data file
| author | luisf <luis.figueira@eecs.qmul.ac.uk> |
|---|---|
| date | Tue, 05 Feb 2013 16:19:56 +0000 |
| parents | 15b82ccc064b |
| children | c6c0578924fa |
| files | python-intro.py |
| diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/python-intro.py Tue Feb 05 16:17:46 2013 +0000 +++ b/python-intro.py Tue Feb 05 16:19:56 2013 +0000 @@ -1,4 +1,9 @@ source = open('data.txt', 'r') +number = 0 + +# count number of data records for line in source: - print line + number = number + 1 source.close() + +print "Total number of lines:", number
