Report Bug

Qus

Read the information given below carefully and write a list comprehension such that the output is: [‘e’, ‘o’]

  w="hello"  v=('a', 'e', 'i', 'o', 'u')
Qusनीचे दी गई इन्फॉर्मेशन को ध्यान से पढ़ें और एक लिस्ट लिखें जैसे कि आउटपुट है: [given e ',] o']


A. [x for w in v if x in v]
B. [x for x in w if x in v]
C. [x for x in v if w in v]
D. [x for v in w for x in w]


Solution
B. [x for x in w if x in v]



Explanation
The tuple ‘v’ is used to generate a list containing only vowels in the string ‘w’. The result is a list containing only vowels present in the string “hello”. Hence the required list comprehension is: [x for x in w if x in v].
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad