Share your repls and programming experiences

← Back to all posts
palindrome
AmanDeep2 (0)

def palindrome(s):
if s==s[::-1]:
return True
else:
while len(s)>=2:
i=0
num=0
s1=''
while i<len(s)-1:
num=int(s[i])+int(s[i+1])
s1+=str(num)
i+=2
s=s1
print(s)
if s==s[::-1]:
return True
else:
continue
return False

s=input()
print(palindrome(s))

Commentshotnewtop
LizFoster (103)

The moment I run this, it says:

ReferenceError: palindromedescendant is not defined
    at /home/runner/ehbflew23q5/index.js:12:17
    at Script.runInContext (vm.js:133:20)
    at Object.<anonymous> (/run_dir/interp.js:156:20)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)