0

What is mistake in my code ?

You are walking from your house to a pond that is down your street. How many blocks over will you have to walk until you get to the pond? Task: Evaluate how many blocks you will have to walk if you are given a representation of your street where H represents your house, P represents the pond, and every B represents a block in between the two. Input Format: A string of letters representing your house, the pond, and blocks on your street. Output Format: An integer value that represents the number of blocks between your house and the pond. Sample Input: BBHBBBBPBBB Sample Output: 4

19th Jul 2021, 4:40 AM
Rotace
Rotace - avatar
1 Answer
+ 1
Code:text=input() ind=text.index("P")-1 ind2=text.index("H") D=ind-ind2 print(D)
19th Jul 2021, 4:41 AM
Rotace
Rotace - avatar