Advertisement
Guest User

Esercizio (Python.it)

a guest
Jun 24th, 2015
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. def main():
  2.     s = input("please enter a s:")
  3.     stringa = A_Ex1(s)
  4.     print("Risultato:",stringa)
  5.  
  6. def A_Ex1(s):
  7.     lista = [ord(i) for i in s]
  8.     count = 0
  9.     for x in range(len(lista)):
  10.         if x == 0:
  11.             if lista[x] < lista[x+1]:
  12.                count += 1
  13.         elif x == len(lista)-1:
  14.             if lista[x] > lista[x-1]:
  15.                count += 1
  16.         else:
  17.             if lista[x] > lista[x-1] and lista[x] < lista[x+1]:
  18.                 count += 1
  19.     return int(count)
  20.  
  21. #Lanciamo main
  22. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement