aboutsummaryrefslogtreecommitdiff
path: root/challenge-273/eric-cheung/python/ch-2.py
blob: 2b9c57d3627a54cd8e42cd012b7c8d883e39c1ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## strInput = "aabb"  ## Example 1
## strInput = "abab"  ## Example 2
## strInput = "aaa"  ## Example 3
strInput = "bbb"  ## Example 4

if strInput.count("b") <= 1:
    print (False)
else:
    nFirstBPos = strInput.index("b")

    nNumOfA = strInput[nFirstBPos + 1:].count("a")
    nNumOfB = strInput[nFirstBPos + 1:].count("b")

    print (nNumOfA == 0 and nNumOfB > 0)