Change language

Python program to remove the i-th character from a string


In any line, indexing always starts from 0. Suppose we have lines obsessed with it, then its indexing will be as follows:

 geeks 0 1 2 3 4 


 Input: Geek i = 1 Output: Gek Input: Peter i = 4 Output: Pete 

Approach: from the given line, the i-th indexed element must be removed. So, split the string into two halves, before the indexed character and after the indexed character. Return the concatenated string.

Below is the implementation of the above approach:

# Python3 program to remove the i-th
# indexed character from string

# Removes character at index i

def remove (string, i): 


# Characters before indexing i

# stored in variable a

a = string [: i] 


  # Characters after indexing nth

# stored in variable b

b = string [i + 1 :]


  # Return the string after deletion

  # nth indexed character.

  return a + b

Driver code

if __ name__ = = ’__main__’ :


string = " geeksFORgeeks "


# Remove the nth index element

i = 5


  # Print a new line

print (remove (string, i))



Python program to remove the i-th character from a string Python functions: Questions

Python program to remove the i-th character from a string String Variables: Questions


Best laptop for Fortnite


Best laptop for Excel


Best laptop for Solidworks


Best laptop for Roblox


Best computer for crypto mining


Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers



Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method