The problem is that you are trying to use simple quotes inside a string created with simple quotes. The result is an unintentional closure of the string - leaving out the letter A
of it - and opening a new string in the sequence.
To solve the problem, just use double quotes to create the string, as in the code below:
print(f" {(p.find('A'))}")
In addition, the method find()
is only used to get the position of a substring. To count how many times a substring appears in the string, use the method count()
, thus:
print(f" {p.count('A')}")