How can i make user enter "string" and enter (index) and remove this (index) from "string" which he entered?

Question:


Text = input(">> Please, Enter The Text: ")
index_X = input(">> Please, Enter The index_X which you want to remove from 'Text': ")
print(Text.remove(index_X))

i tried to use replace method
but i think there is another way

Asked By: KHALED REDA

||

Answers:

You could take the piece of the string prior to the index and then the piece of the string after the index and put them together.

Text = input(">> Please, Enter The Text: ")
index_X = int(input(">> Please, Enter The index_X which you want to remove from 'Text': ")) #convert to int
new_text = Text[:index_X] + Text[index_X+1:]
print(new_text)
Answered By: scotscotmcc
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.