Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mylist1=[] #Bulunan karakterler bu listeye atilacak.
- def before(location):
- #Her bulunan kucuk karakter icin, onceki 1. 2. ve 3. karakterin buyuk harfli olup olmadigini kontrol ediyor.
- if sentence[location-1].isupper() is True:
- if sentence[location-2].isupper() is True:
- if sentence[location-3].isupper() is True:
- return True
- else:
- return False
- #Ayni sekilde, her bulunan kucuk karakterin sonraki 1. 2. ve 3. karakterinin buyuk harfli olup olmadigini kontrol ediyor.
- def after(location):
- if sentence[location+1].isupper() is True:
- if sentence[location+2].isupper() is True:
- if sentence[location+3].isupper() is True:
- return True
- else:
- return False
- #Bu dongu de stringi tek tek karakterlerine ayiriyor, karakteri "char" olarak kaydediyor, konumunu da "index".
- for index,char in enumerate(sentence):
- # print index
- # print char
- # if char.islower() is True: #bu alternatif kod, yani alttaki yerine bunu da denedim.
- # if before(index) is True:
- # if after(index) is True:
- # mylist.append(char)
- #bu da diger secenek
- if char.islower() is True:
- if sentence[index-1].isupper() and sentence[index-2].isupper() and sentence[index-3].isupper() is True:
- if sentence[index+1].isupper() and sentence[index+2].isupper() and sentence[index+3].isupper() is True:
- mylist1.append(char)
- #bunlari test icin yazmistim, konuyla pek alakasi yok aslında. Ama bu testler dogru donduruyor.
- # print "%s is lowercase\n and it's index is %s" %(char, index)
- # print "previous character is: %s" %(sentence[index-1])
- # elif char.isupper():
- # print "%s is uppercase\n and it's index is %s" %(char, index)
- # print "previous character is: %s" %(sentence[index-1])
- print mylist1
Advertisement
Add Comment
Please, Sign In to add comment