Python-Quizzes | Python List Quiz | Question 18
Find the output of the following program:
Python3
temp = [ 'Geeks' , 'for' , 'Geeks' ]
arr = [i[ 0 ].upper() for i in temp]
print (arr)
|
(A)
[‘G’, ‘F’, ‘G’]
(B)
[‘GEEKS’, ‘FOR’, ‘GEEKS’]
(C)
[‘GEEKS’]
(D)
Compilation error
Answer: (A)
Explanation:
The variable i is used to iterate over each element in list temp. i[0] represent the character at 0th index of i and .upper() function is used to capitalize the character present at i[0].
Quiz of this Question
Please comment below if you find anything wrong in the above post
Last Updated :
17 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...