Python Practice › String Programs › Program 94

Remove the kth character

EasyString Programs · 94 of 106

Write a Python program to remove the character at index k.

Advertisement
Input
k = 2, "sqatools"
Output
sqtools

Approach

  1. Join the parts before and after index k.

Solution

Python
text, k = "sqatools", 2print(text[:k] + text[k + 1:])
Output
sqtools
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs