Pages

Bangladeshi Blog
Showing posts with label list. Show all posts
Showing posts with label list. Show all posts

Friday, January 14, 2011

7757. Flowers Flourish from France

code:
while True: 
    line = str(raw_input()) 
    if line == '*': 
        break 

    s = [x.lower() for x in line] 

    # Removing leading spaces 
    while s: 
        temp = s.pop(0) 
        if temp != ' ': 
            s.insert(0, temp) 
            break 
         
    # Removing trailing spaces 
    while s: 
        temp = s.pop() 
        if temp != ' ': 
            s.append(temp) 
            break 

     
    check = s.pop(0) 
    ls = len(s) 
    i = 0 
    flag = True 
     
    while i < ls: 
        if s[i] == ' ': 
            if s[i+1] == check: 
                flag = True 
                i += 2 
            else: 
                flag = False 
                break 
        else: 
            i += 1 

    if flag: 
        print 'Y' 
    else: 
        print 'N' 

## End of Source Code
Be Pythonic