Re: [Tutor] 'open' is not defined

2015-07-31 Thread ltc.hotspot
Hi Emile, I hope this answers your question? Question: How do I remove each duplicate line output? Here is the raw data code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 for line in fh: if not line.startswith('

Re: [Tutor] 'open' is not defined

2015-07-30 Thread Steven D'Aprano
On Thu, Jul 30, 2015 at 11:41:56PM +, ltc.hots...@gmail.com wrote: > Hi Everyone: > > > Why is open not defined in the following code:NameError: name 'open' is not > defined Are you still running your code on the PythonTutor website? http://pythontutor.com/visualize.html says in the fine-

Re: [Tutor] 'open' is not defined

2015-07-30 Thread Emile van Sebille
On 7/30/2015 4:41 PM, ltc.hots...@gmail.com wrote: Hi Everyone: Why is open not defined in the following code:NameError: name 'open' is not defined Because of something you did previously. We don't have enough information to answer. open exists as a built-in function in python: Python 2

[Tutor] 'open' is not defined

2015-07-30 Thread ltc.hotspot
Hi Everyone: Why is open not defined in the following code:NameError: name 'open' is not defined Code reads as follows: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 for line in fh: if not line.startswith('From'): continue