w3resource logo


Python Exercises

Python: Remove the nth index character from a non empty string


Write a Python program to remove the nth index character from a non empty string.

Sample Solution :

Python Code :

def remove_char(str, n):
      first_part = str[:n] 
      last_pasrt = str[n+1:]
      return first_part + last_pasrt
print(remove_char('Python', 0))
print(remove_char('Python', 3))
print(remove_char('Python', 5))

Console :

Copy and paste the above code and press "Enter key" to execute :

Post your code through Disqus