Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 11 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
laylasnii13: Can i dm anybody to vent having a rough time ??
9 hours ago 1 Reply 0 Medals
kaelynw: starting to draw a hand
8 hours ago 15 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
9 hours ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
8 hours ago 4 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
1 day ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
1 day ago 27 Replies 3 Medals
kaelynw: art igg
1 day ago 14 Replies 1 Medal
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!