I am learning to do some string manipulation python as you can see below trying to insert a character, but after some run it fails. Can you explain why ?
phone_num = str("+1-202-555--+0143+")
wrng = ['+','-']
for a in phone_num:
if a in wrng:
b = phone_num.find(a)
c = phone_num.rfind(a)
if type(b)!= int or float:
phone_num = phone_num[:b]+'0'+phone_num[b:]
print(phone_num)
elif type(c) != int or float:
phone_num = phone_num[:c]+'0'+phone_num[c:]
else:
print("Wrong")
also trying to add the end but it fails.
0+1-202-555--+0143+
0+10-202-555--+0143+
0+100-202-555--+0143+
0+1000-202-555--+0143+
0+10000-202-555--+0143+
00+10000-202-555--+0143+
000+10000-202-555--+0143+
expecting was 0+1-202-555-0-0+0143+0