Earlier quoted context omitted.
Deliberately-straightforward -- agreed. But "highly proficient" after writing one or two scripts? That's quite a stretch. For instance, one of the questions I give in phone screens is for the candidate to write a program to count the number of occurrences of unique words in a text file. The "after writing one or two Python scripts" approach is something like this: counts = {} f = open('test.txt') lines = f.read().spl…
My solution: lines = [line for line in open("bible.txt")] words = [word for line in lines for word in line.split()] counts = {word:0 for word in words} for word in words: counts[word] += 1 No imports needed. Linear time. A bit inefficient in the dictionary comprehension, but easy to read. The "lines=" and "words=" can be compressed into one line, but I figure this is a bit easier to read for people who aren't familia…
lines = [line for line in open("bible.txt")]
words = [word.lower() for line in lines for word in line.split()]
counts = {word:0 for word in words}
for word in words:
counts[word] += 1