
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program for removing n-th character from a string?
String means array of character so starting address is 0.then we can easily get the index of every character. We have to input that index no. then remove that element. So split the string into two sub string. And two part should be one before n th indexed character and another after indexed character, the merged this two string.
Example
Input: python n-th indexed: 3 Output: pyton
Explanation

Algorithm
Step 1: Input a string. Step 2: input the index p at the removed character. Step 3: characters before the p-th indexed is stored in a variable X. Step 4: Character, after the n-th indexed, is stored in a variable Y. Step 5: Returning string after removing n-th indexed character.
Example code
# Removing n-th indexed character from a string def removechar(str1, n): # Characters before the i-th indexed is stored in a variable x x = str1[ : n] # Characters after the nth indexed is stored in a variable y y = str1[n + 1: ] # Returning string after removing the nth indexed character. return x + y # Driver Code if __name__ == '__main__': str1 = input("Enter a string ::") n = int(input("Enter the n-th index ::")) # Print the new string print("The new string is ::") print(removechar(str1, n))
Output
Enter a string:: python Enter the n-th index ::3 The new string is :: pyton
- Related Questions & Answers
- Java program for removing n-th character from a string
- Python program for removing nth character from a string
- C# program to remove n-th character from a string
- Removing nth character from a string in Python program
- C# program to replace n-th character from a given index in a string
- Python Program for n-th Fibonacci number
- C Program for n-th even number
- C Program for n-th odd number
- Java Program for n-th Fibonacci number
- Removing n characters from a string in alphabetical order in JavaScript
- N-th Fibonacci number in Python Program
- Program for n’th node from the end of a Linked List in C program
- Program to find Kth bit in n-th binary string using Python
- C/C++ Program for the n-th Fibonacci number?
- C# Program to change a character from a string
Advertisements