[ create a new paste ] login | about

Link: http://codepad.org/9kHIFqks    [ raw code | fork ]

Python, pasted on Oct 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#Palindrome Iterative Style.

def caller():
    x = raw_input('Enter the string for checking. ')
    # should work on the string without making it a list
    return tester(x)

def tester(x):
    count = 0
    for i in range(0, int(len(x)/2)+1):
        # if any of these do NOT match, it is not a palindrome
        if x[i] != x[-i-1]:
            return False
    # if you got here all the tests passed
    return True

if caller():
    print 'Congo u ve just found a Palindrome!'
else:
    print 'test failed!'


Create a new paste based on this one


Comments: