s = ''
print('Enter a string other than empty:')
while s == '':
s = input('>>> ? ')
n = 0
print('Enter the position of the character to be deleted,')
print(f'an integer from {1} to {len(s)}')
while n == 0:
try:
n = int(input('>>> ? '))
if n < 1 or n > len(s):
print('Incorrect value range please re-enter')
n = 0
except ValueError:
print('Invalid input please try again')
s1 = s[:n-1] + s[n:]
print('Removal result: ',s1)
p = input('Enter character: ')
print('Quantity ',s.count(p))
print('Appearance percentage: ',round(s.count(p)*100/len(s),2),'%')
Comments
Leave a comment