Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 19 Online
OpenStudy (anonymous):

#This program tends to test for a palindrome iteratively. Please help find buG. def tester(): z = list('malyaylam') count = 0 for i in range(0, int(len(z)/2)+1): if z[i] == z[-i-1] and i <= int(len(z)/2): count += i if count == int(len(z)/2): print 'Congo u ve just found a Palindrome!' else: pass else: 'test failed!' tester()

OpenStudy (anonymous):

1. "else: pass" is not necessary. 2. I think you have indentation problems with your second if and both else statements. 3. Add a bunch of print statements to make sure variables are doing what you think they're doing. 4. Reread each line carefully. One line in particular has a pretty obvious problem. Explain in words what you want the algorithm to do.

OpenStudy (anonymous):

pls use a code pasting site to post your code, it makes it easier for us to comment. http://dpaste.com/641394/

OpenStudy (anonymous):

fixed tester() , by changing count += i to count += 1. here's improved code: http://dpaste.com/641531/

OpenStudy (anonymous):

#Palindrome Iterative Style. def listmaker(L): global z z = list(L) def caller(): global x x = raw_input('Enter the string for checking. ') listmaker(x) tester() def tester(): count = 0 for i in range(0, int(len(z)/2)+1): if z[i] == z[-i-1] and i <= int(len(z)/2): count += 1 if count == int(len(z)/2): print x, 'Is a Palindrome!' break else: print x, 'is not a palindrome...' caller()

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Alexander071105: ft
3 minutes ago 1 Reply 0 Medals
brianagatica14: Any artist on here?
4 hours ago 7 Replies 2 Medals
Uniful3: Art dump..
6 hours ago 8 Replies 1 Medal
mimix: hii i miss everyone
1 day ago 4 Replies 0 Medals
hellokitty265: Art
23 hours ago 13 Replies 1 Medal
TarTar: Any Songwriters here???
10 hours ago 26 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!