I want to get 59,000 but I can't get what I want.
a='5M 9,000'
a.strip('M')
You can use Regex module's sub() function, this returns a string where all matching occurrences of the specified pattern are replaced by the replace string.
Note:- '\D' is used to match all decimals, i think you're trying to extract numbers from the string?
import re
a = '5M 9,000'
a=re.sub(r'\D', '', a)#59000
print(f'{int(a):,}')
OUTPUT
59,000
Delete a single char at a specified location
a = '5M 9,000'
a = a[:c]+a[c+1:]
where c is the location of the char
For deleting multiple chars starting from a specified location
a = '5M 9,000'
a = a[:c]+a[c+length:]
where length is the number of chars you want to remove starting from the location c
a = '5M 9,000'
c = 3
a = a[:c]+a[c+1:]
a will be '5M ,000'
a = '5M 9,000'
c = 3
length = 2
a = a[:c]+a[c+length:]
a will be '5M 000'
making it into 59,000
a = '5M 9,000'
c = 1
length = 2
a = a[:c]+a[c+length:]
output
a is '59,000'
a = a[:1]+a[3:]
a = a.replace("M ", "")?Mstand for "million?" If so, then do you want 5,009,000 as the output?