Python Practice › List Programs › Program 95
Remove the 2nd character of each word
Write a Python program to remove the 2nd character of each word.
Input
["Hello", "student", "are", "learning", "Python", "Its", "Python", "Language"]
Output
['Hllo', 'sudent', 'ae', 'larning', 'Pthon', 'Is', 'Pthon', 'Lnguage']
Approach
- Join the slices before and after index 1.
Solution
words = ["Hello", "student", "are", "learning", "Python", "Its", "Python", "Language"]print([w[0] + w[2:] for w in words])Output
['Hllo', 'sudent', 'ae', 'larning', 'Pthon', 'Is', 'Pthon', 'Lnguage']
Learn the concept
New to this topic? Read the lesson, then come back.