CBSE Class 11 Computer Science
Question 51 of 82
Lists in Python — Question 16
Back to all questions['CC', 'a', 'm', '@', 'D', '22', 'D', '*']
In the given code, Str2 is initialized as a list of characters from the string "Cam@123*", resulting in ['C', 'a', 'm', '@', '1', '2', '3', '*']. The for loop iterates over the indices of Str2 from 0 to len(Str2) - 1. Within the loop, three conditions modify the elements of Str2: if the index i is 5, the character at Str2[i] is multiplied by 2, if the character is uppercase, it is also multiplied by 2, if the character is a digit, it is replaced with 'D'. After the loop, Str2 becomes ['CC', 'a', 'm', '@', 'D', '22', 'D', '*'], which is printed as the final output.