KeyError. The lines are numbered from 1.
groups = {}
for word in ["ant", "bee", "ape", "bat"]:
k = word[0]
groups[k].append(word)
print(groups)
Which changes make the program print {'a': ['ant', 'ape'], 'b': ['bee', 'bat']}? Choose two.One or more options are correct. Tick all the correct ones: a wrong option costs marks, and a part-right answer earns part of the marks.
Log in to join the discussion.
Loading…