Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. def najdaljsaBeseda(niz):
  2.  
  3. text=niz
  4. zacetek=0
  5. konec=0
  6. seznamBesed=[]
  7. locila=["." , "," , "!" , "?" , " "]
  8. for i in range(len(text)):
  9. if(text[i] in locila):
  10. podtext=text[zacetek:konec]
  11. zacetek=konec+1
  12. konec=zacetek
  13. seznamBesed.append(podtext)
  14. else:
  15. konec+=1
  16.  
  17. maksi=-9999
  18. p=[]
  19. for i in range(len(seznamBesed)):
  20. if(seznamBesed[i] not in p):
  21. st=0
  22. for j in range(len(seznamBesed)):
  23. if(seznamBesed[i]==seznamBesed[j]):
  24. st+=1
  25. if(st>maksi):
  26. maksi=st
  27. index=i
  28. p.append(seznamBesed[i])
  29. print(seznamBesed[index])
  30.  
  31. najdaljsaBeseda("a AA GH GH GG GG g g g g g g.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement