Advertisement
Guest User

Untitled

a guest
Dec 5th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. palabras = raw_input("Ingrese las palabras: ")
  2.  
  3. contador = 0
  4.  
  5. asc = 0
  6. des = 0
  7.  
  8. inicio = 0
  9.  
  10. anterior = 0
  11.  
  12. for palabra in palabras:
  13.     if palabra == " " or palabra == ".":
  14.        
  15.         if inicio == 0:
  16.             anterior = contador
  17.             inicio = 1
  18.             contador = 0
  19.             continue
  20.  
  21.         print anterior, contador
  22.         if anterior > contador:
  23.             des = 1
  24.         elif anterior < contador:
  25.             asc = 1
  26.         anterior = contador
  27.         contador = 0
  28.        
  29.     else:
  30.         contador += 1
  31. else:
  32.     if des and asc:
  33.         print "Ninguno"
  34.     elif des == 1:
  35.         print "descendiente"
  36.     elif asc == 1:
  37.         print "Ascendente"
  38.     else:
  39.         print "Ninguno"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement