From c05a6582fb9a6bd6aa8ea462c77213b9215b470a Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 30 Apr 2017 19:09:13 +0200 Subject: palindromo c++ in python --- python/palindroma.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 python/palindroma.py (limited to 'python') diff --git a/python/palindroma.py b/python/palindroma.py new file mode 100644 index 0000000..af82a04 --- /dev/null +++ b/python/palindroma.py @@ -0,0 +1,15 @@ +def palindromo(parola, start, end): + if start >= end: + return True + elif parola[start] == parola[end]: + return palindromo(parola, start+1 , end-1) + else: + return False + + +parola = input('Parola: ') + +if palindromo(parola, 0, len(parola)-1): + print('Palindroma') +else: + print('Non palindroma') -- cgit v1.2.3-18-g5258