Guest User

zxczvcxzvqerqz

a guest
Nov 22nd, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. mylist1=[]   #Bulunan karakterler bu listeye atilacak.
  2.  
  3.    
  4. def before(location):  
  5. #Her bulunan kucuk karakter icin, onceki 1. 2. ve 3. karakterin buyuk harfli olup olmadigini kontrol ediyor.
  6.     if sentence[location-1].isupper() is True:
  7.         if sentence[location-2].isupper() is True:
  8.             if sentence[location-3].isupper() is True:
  9.                 return True
  10.     else:
  11.         return False
  12.  
  13. #Ayni sekilde, her bulunan kucuk karakterin sonraki 1. 2. ve 3. karakterinin buyuk harfli olup olmadigini kontrol ediyor.
  14. def after(location):
  15.     if sentence[location+1].isupper() is True:
  16.         if sentence[location+2].isupper() is True:
  17.             if sentence[location+3].isupper() is True:
  18.                 return True
  19.     else:
  20.         return False
  21. #Bu dongu de stringi tek tek karakterlerine ayiriyor, karakteri "char" olarak kaydediyor, konumunu da "index".
  22.  
  23. for index,char in enumerate(sentence):
  24. #   print index
  25. #   print char
  26. #   if char.islower() is True: #bu alternatif kod, yani alttaki yerine bunu da denedim.
  27. #       if before(index) is True:
  28. #           if after(index) is True:
  29. #               mylist.append(char)
  30.  
  31. #bu da diger secenek
  32.     if char.islower() is True:
  33.         if sentence[index-1].isupper() and sentence[index-2].isupper() and sentence[index-3].isupper() is True:
  34.             if sentence[index+1].isupper() and sentence[index+2].isupper() and sentence[index+3].isupper() is True:
  35.                 mylist1.append(char)
  36.  
  37.  
  38.  
  39. #bunlari test icin yazmistim, konuyla pek alakasi yok aslında. Ama bu testler dogru donduruyor.
  40. #       print "%s is lowercase\n and it's index is %s" %(char, index)
  41. #       print "previous character is: %s" %(sentence[index-1])
  42. #   elif char.isupper():
  43. #       print "%s is uppercase\n and it's index is %s" %(char, index)
  44. #       print "previous character is: %s" %(sentence[index-1])
  45.  
  46. print mylist1
Advertisement
Add Comment
Please, Sign In to add comment