Python Practice › List Programs › Program 95

Remove the 2nd character of each word

EasyList Programs · 95 of 100

Write a Python program to remove the 2nd character of each word.

Advertisement
Input
["Hello", "student", "are", "learning", "Python", "Its", "Python", "Language"]
Output
['Hllo', 'sudent', 'ae', 'larning', 'Pthon', 'Is', 'Pthon', 'Lnguage']

Approach

  1. Join the slices before and after index 1.

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment