5
I need to write a program that identifies a lowercase letter surrounded by three uppercase letters on each side.
For example:
"AEIoSDE" == "o"
I wrote the code as follows:
# coding: utf-8
letra = raw_input()
for i in range(1, len(letra) - 7):
if letra[i].isupper() and not letra[i-1].isupper():
if letra[i+1].isupper():
if letra[i+2].isupper():
if letra[i+3].islower():
if letra[i+4].isupper():
if letra[i+5].isupper():
if letra[i+6].isupper() and not letra[i+7].isupper():
print letra[i+3]
Only I need to do this for a massive amount of data, so I saved it in a file .txt
and entered the Linux terminal and typed:
python criptografia.py < entrada.txt
Only it returns me only one letter and does not read the other strings.
How can I solve?
Why did you put
len(letra) - 7
?– Paulo
@Orion, because it checks from the current position. If you do not will exit the vector string.
– Mansueli