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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz