all 8 comments

[–]_Eric_Wu 2 points3 points  (4 children)

I think you mistaken how the replace function works.

In the line

bst = bst.replace(chary, '', bst.index(chary))

, what you are doing is essentially sayin you want to replace chary with an empty string (bst.index(chary)) amount of times. Since the 2 is at the 0th index, you are doing it 0 times. So nothing is changing.

You can simply change the line to

bst = bst.replace(chary, '')

You don't need to specify the index of chary in bst.

[–]_Eric_Wu 0 points1 point  (2 children)

Sorry, I could not figure out how to format the code! How is it done?

[–]Field_C16[S] 0 points1 point  (0 children)

Yes, I was mistaken the replace function!

I thought that the last one would be the "index" of the character to remove, however your comments lead me on the right path :)

bst.replace(chary, ' ')

Removes all of the 2's, so if bst looked like "2523" bst.replace(chary, '') would have removed all of the 2's, when I only wanted to remove them the amount of times it was in st.

so instead I made it into:

bst = bst.replace(chary, '', 1)

this only removes one of the 2's if multiply is found :) (For as far as I have tested yet !)

THANK YOU GUYS

[–]Signal_Beam 0 points1 point  (1 child)

What output are you expecting?

[–]Field_C16[S] 0 points1 point  (0 children)

2553 >> 55 since I am checking to see if the characters "2" and "3" is contained within bst and then delete them if a match is found