Shakespeare: Difference between revisions

imported>Zanwenhuahao
imported>Zanwenhuahao
Line 81:
 
7. Does Shakespeare use a lot of love in his plays? How about other synonyms of "love"?
 
====Lists====
* Recall that lists in Python can contain <b>arbitrary objects</b> and <b>dynamically expanded</b> as new things "arrive" to fill up the list
* We may declare our list as such
<pre>
>>> lst=["William","Shakespeare"]
>>> lst
['William', 'Shakespeare']
</pre>
* We may <b>append</b> something to our list as such
<pre>
>>> lst.append("Bard of Avon")
>>> lst
['William', 'Shakespeare', 'Bard of Avon']
</pre>
* More on list operations can be fount at the following URL: [https://docs.python.org/2/tutorial/datastructures.html]
* One common way to process a file is to open it, and save each line as a string into a list
<pre>
</pre>
Anonymous user