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
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)
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
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)