Report Bug

Qus

What will be the output of the following Python code?

  l=["good", "oh!", "excellent!", "#450"]  [n for n in l if n.isalpha() or n.isdigit()]
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. [‘good’, ‘oh’, ‘excellent’, ‘450’ ]
B. [‘good’]
C. [‘good’, ‘#450’]
D. [‘oh!’, ‘excellent!’, ‘#450’]


Solution
B. [‘good’]



Explanation
The code shown above returns a new list containing only strings which do not have any punctuation in them. The only string from the list which does not contain any punctuation is ‘good’. Hence the output of the code shown above is [‘good’].
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