Rosfield40
New Coder
I am stumped on why I can't delete a certain number of specific characters from a string
I get this;
TypeError: replace() argument 2 must be str, not int
I understand it is telling me I cannot use an integer where the '1' is, but how else do I do this? I've looked online and I can't see what I am doing wrong?
Sorry I am an absolute beginner, and only coding a few days
EDIT: SORRY. Figured it out, I needed a blank for 2nd arg. (been looking at this for an hour and only figure it out as soon as I post! Apologies!
Code:
str = "banana"
str_new = str.replace('a', 1)
print(str_new)
I get this;
TypeError: replace() argument 2 must be str, not int
I understand it is telling me I cannot use an integer where the '1' is, but how else do I do this? I've looked online and I can't see what I am doing wrong?
Sorry I am an absolute beginner, and only coding a few days
EDIT: SORRY. Figured it out, I needed a blank for 2nd arg. (been looking at this for an hour and only figure it out as soon as I post! Apologies!
Last edited: