ICP2 - adrian6912/CS490PythonML GitHub Wiki

  1. Use a hardcoded list of measurements in pounds ([150, 155, 145, 148]) and convert its elements into kilograms by using a list comprehension, ex: [x * 0.45359237 for x in pounds].

  2. Use a hardcoded string ("Good evening") and return the string of every other letter using a slice, ex: [::2].

  3. Have a dictionary called "counter" which will keep track of the word counts of each word. Open a file called "ICP2_Part3.txt", get a list of the lines, split each line into words, then try to increment the value of each key from a dictionary called "counter." If this raises a KeyError, then the key hasn't been initialized yet. Set it to 0. Then, iterate through the keys of "counter" and write the name of each word followed by its count to the original file.