CBSE Class 12 Computer Science
Question 86 of 105
Python Revision Tour II — Question 13
Back to all questionsThere are two issue in range(len(words), 0, -1):
- The start index
len(words)is invalid for the listwordsas it will have indexes from 0 tolen(words) - 1. - The end index being 0 means that the last element of the list is missed as the list will be iterated till index 1 only.
The corrected python code is :
for i in range(len(words)-1, -1, -1):
print(words[i], end=' ')