COMP 102 Lecture 8: Comp102-Week8
Document Summary
The principle that spam algorithms use to sort through junk mail in your inbox. Counting is at the heart of very sophisticated algorithms. Whenever we are in a list, we can (as in line 12 of count_the. py), we have a loop that goes through every item in the list. If item matches what you want, counter goes up by one. String cleaning (or data cleaning ) removes symbols that aren"t of interest. Square brackets is how python gets something out of a list. Can use square brackets even to pull out the first element in a list. = a[0] how you pull the first element out of a string. The zeroth position is always the first element. The square bracket with the zero is called the accessor. Square brackets can also be used to pull a value out of a dictionary. A well designed programming languages should make intuitive sense based on what you already know about it.