<div dir="ltr">Hey Hal - <div><br></div><div>The errors in your code seem to me to come from trying to run before you can walk. Let me give you one example of what should be going through your head:<br></div><div><br></div><div>>>> list.split()</div><div><br></div><div>Why doesn't this work? Well - you have to understand every individual piece of this statement. Start with "list" - that's a builtin data type in Python. The builtins are the things you automatically have access to without importing. If you open a brand new python shell and type list you'll see that list is already there!</div><div><br></div><font face="monospace, monospace">$ python<br>>>> list<br><type 'list'></font><br><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">Next is the "." character. The dot is the attribute operator which allows you to look inside the thing on the left for the thing on the right. The thing on the left is the list type and the thing on the right is named split. Lastly the line has parens "()" which is the call operator. This implies that "split" is a thing in list and the kind of thing is something you can call - a function or a method.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">If I try to run this line of code I get an error:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><font face="monospace, monospace">>>> list.split()<br>Traceback (most recent call last):<br>  File "<stdin>", line 1, in <module><br>AttributeError: type object 'list' has no attribute 'split'</font><br><div><br></div><div>What this is telling me is that the list type has no attribute called split. I could retrieve all the attributes by using another builtin "dir" to verify that this is so:</div><div><br></div><font face="monospace, monospace">>>> dir(list)<br>[... a bunch of  __ugly__ attributes and then... 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']</font><div><br></div><div>Aha! The list type has append, count, extend, index, insert, pop, remove, reverse, sort methods. There is no split method on lists and that's why this line of code crashes...</div><div><br></div><div>You might already know all this stuff but my impression is you are trying to debug a program without understanding the basics - you don't know how to solve your own problems yet because you don't have a firm understanding of the basic syntax and concepts in python.</div><div><br></div><div>Don't feel bad! Everybody is there when they are learning a new language - when I read Haskell code I spend a lot of time saying "I don't know have any idea what this piece of punctuation even means!" But if you're not an experienced developer it helps a lot to get a grounding in the basics of a language before you try to solve problems with it.</div><div><br></div><div>I'd really recommend you try something like Learn Python the Hard Way - see <a href="http://learnpythonthehardway.org/book/">http://learnpythonthehardway.org/book/</a> for the free book. Work through each chapter and don't skip any of the exercises. By the time you hit chapter 10 you ought to be able to complete the exercise you're working on right now and understand each and every line...</div><div><br></div><div>I know it feels like a step back to review basic material instead of working on your problem. But it might be more efficient in the long run - I'm sure it feels frustrating to be blocked and waiting for email responses from the list...</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 28, 2015 at 1:14 PM,  <span dir="ltr"><<a href="mailto:ltc.hotspot@gmail.com" target="_blank">ltc.hotspot@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div dir="ltr" style="font-family:'Calibri','Segoe UI','Meiryo','Microsoft YaHei UI','Microsoft JhengHei UI','Malgun Gothic','sans-serif';font-size:12pt"><div>Hi Everyone,</div><div><br></div><div>I'm writing python code to read a data text file, split the file into a list of words using the split(function) and to print the results in alphabetical order.</div><div><br></div><div>The raw python code is located at <a href="http://tinyurl.com/oua9uqx" target="_blank">http://tinyurl.com/oua9uqx</a></div><div><br></div><div>The sample data is located at <br><a href="http://tinyurl.com/odt9nhe" target="_blank">http://tinyurl.com/odt9nhe</a></div><div><br></div><div><br>Desired Output: ['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder']</div><div><br></div><div>There is a line error on no. 7<br>What is the cause of this error?</div><div><br></div><div><br>Regards,<br>Hal<br></div><div><div><br></div><div>Sent from Surface</div><div><br></div></div></div>
</div>

<br>_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="https://mail.python.org/mailman/listinfo/baypiggies" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/baypiggies</a><br></blockquote></div><br></div></div>