Saint Louis University |
Computer Science 1300/5001
|
Computer Science Department |
Topic: Comprehension syntax
Related Reading: Ch. 09
Due:
10:00am, Tuesday 2 October 2018
Please make sure you adhere to the policies on academic integrity.
Assume that tokens is a list of strings read from a
text file, that represent numeric values (e.g.,
Give a single line that uses comprehension syntax to produce a
new list, named vals, which are the corresponding
integer values (e.g.,
Assume that nouns is a list of strings. Given a line that produces a new list, plural, containing all of the original words that end with the character 's'. (Yes, I realize that these might not actually represent plurals, but this is just an exercise.)
On our recent exam there was a question that involved
converting a phrase such as
We could accomplish the goal using traditional techniques as in the following:
initials = [] for word in phrase.split(): initials.append(word[0].upper()) acronym = ''.join(initials)
Your task is to give a single line of code of the form
acronym = ???that accomplishes the above task.