Python palindrome programming -


the code bit messy, point divide different functions.

i understand can test palindrome how use boolean variable, instead of stating straight away print function.

def trial():     palindrome = true      c = str(input("hey: "))      in range(len(c)):         = c[i]         s = c[-(i+1)]     if  (a == s):                return      break     else:         print ("no, not plaindrome")     break      return palindrom   def output():     print true   trial() output() 

you can use return value within function

def ispalindrome(s):     return s == s[::-1]  def output(s):     if ispalindrome(s):           # use return value of above function         print('it palindrome')     else:         print('not palindrome') 

for example

>>> output('hello') not palindrome  >>> output('abcba') palindrome 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -