Make a beautiful binary string This is the &quot;Beautiful Binary String&quot; problem at HackerRank:

Alice has a binary string. She thinks a binary string is beautiful if and only if it doesn't contain the substring 010.
In one step, Alice can change a 0 to a 1 or vice versa. Count and print the minimum number of steps needed to make Alice see the string as beautiful.
For example, if Alice's string is 010 she can change any one element and have a beautiful string.

This is my Python code:
def beautifulBinaryString(b):
    temp = list(b)
    count,i = 0,0
    if len(b) == 3 and b == &quot;010&quot;: count += 1
    elif len(b) == 3 and b != &quot;010&quot;: count = count
    else:
        while (i+3 &lt;= len(temp)):
            if temp[i:i+3] == ['0','1','0']: 
                count += 1
                del temp[i:i+3]
            else: i += 1
    return count

It seems to me as having too many conditionals (though readable, I guess). Is there a more concise way to accomplish this?
Some test cases:
0101010 
01100

2
0
Style


Read the PEP8 style guide!


Functions and variables should be snake_case
Conditions should be on the next line if a: ... is bad style
Conditions don't need parenthesis while (a) is the same as while a:
Avoid temp variables



Algorithm


Your first 2 guard clauses seem very unnecessary

When I remove them, the code still works.
Consider writing docstring/tests or both with the doctest module


Alternative Code

You could use re.findall(substring, string) for counting the occurrence, 

OR string.count(substring) making this practically a one-line

import doctest

def beautiful_binary_string(b):
    """
    Returns the steps to make a binary string beautiful

    &gt;&gt;&gt; beautiful_binary_string("0101010")
    2

    &gt;&gt;&gt; beautiful_binary_string("01100")
    0

    &gt;&gt;&gt; beautiful_binary_string("0100101010100010110100100110110100011100111110101001011001110111110000101011011111011001111100011101")
    10
    """
    return b.count("010")

if __name__ == '__main__':
    doctest.testmod()