3. Removing a character from a string Write a function remove() that asks the user to enter a string and an index, and displays the string with the character at that index removed. You may assume the given index is within the string. For example, removing the character at index 2 in "hello" should produce "helo". Hint: Use slicing.
CODE :
def remove():
string = input("Enter the string: ")
index = int(input("Enter the index to remove: "))
new_string = string[:index] + string[index+1:]
print(new_string)
remove()
_______________________________________________________________________________________________
refer this for indentation and sample output:
Get Answers For Free
Most questions answered within 1 hours.