summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-04-30 19:09:13 +0200
committerSanto Cariotti <sancn@live.com>2017-04-30 19:09:13 +0200
commitc05a6582fb9a6bd6aa8ea462c77213b9215b470a (patch)
treea097f755deb5751c8eb269ae8172ab9402385682 /python
parenteb49a77ea66cf0030fc18c8972435b1e33d47b11 (diff)
palindromo c++ in python
Diffstat (limited to 'python')
-rw-r--r--python/palindroma.py15
1 files changed, 15 insertions, 0 deletions
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')