Question 1
What will be the output of the following Python code?
words = ["jacket", "cap", "scarf", "hat", "sock"]
result = []
for idx, word in enumerate(words):
if idx % 2 == 0:
result.append(word[:2].upper() + str(idx))
elif len(word) > 4:
result.append(word[::-1][:3])
else:
result.append("0" + word[-1])
print(result)
['JA0', 'pa0', 'SC2', 'tah', 'SO4']
['JA0', '0p', 'SC2', 'tah', 'SO4']
['JA0', '0p', 'SC2', '0t', 'SO4']
['JA0', '0p', 'SC2', '0t', '0k']
