How far? on Python
Hello everybody! I'm solving a problem called how far away? Where the following conditions are described : "You walk from your house to the pond that is on your street. How many blocks do you have to walk before you reach the pond? Task: Estimate how many blocks you will have to walk if you are given a representation of your street, where X represents your house, p represents a pond, and each block B represents in between. Input format: A string of letters representing your home, pond, and neighborhoods on your street. Output format: An integer value representing the number of blocks between your house and the pond. Entering a sample: BBHBBBBPBBB Example Output: 4 " my solution does not work for the test number 3 and 4. I can not understand what is the matter. here is my solution text = input (). upper () data = list (text [text. index ('H') + 1: text. index ('P')]) print (len (data))