-1
Considering the following list:
lista_nomes =['Manuel', 'Laura', 'Antonio', 'Jasmim', 'Maria', 'Silvia', 'Lu', 'Pancrácio', 'Diogo', 'Ricardo', 'Miguel', 'Andre',]
*
What I want is to print out the elements of the list that end with the letter ' a'.
Well, for a list of integers, I could do like this:
>>> L = [1, 1, 2, 3, 5, 8, 13, 21]
>>> L[-1]
21
I know I could do it like this:
lista_nomes =['Manuel', 'Laura', 'Antonio', 'Jasmim', 'Maria', 'Silvia', 'Lu', 'Pancrácio', 'Diogo', 'Ricardo', 'Miguel', 'Andre',]
print(lista_nomes[1:2])
print(lista_nomes[5:6])
print(lista_nomes[4:5])
But I don’t think it’s okay!
Any ideas, please?!
Thank you,
That’s what I wanted!!! Thank you very much!!! Excellent!
– Joao Peixoto Fernandes
@Joaopeixotofernandes, you can do the same of my last example in
for
: https://repl.it/repls/PrimeMilkyBot– Miguel
Yeah, I know. That’s just it!! :)
– Joao Peixoto Fernandes
Like you said, "What I want to do is print...", which is why I made the first example with
print
. Next time say you want a list (;– Miguel
what I meant was even with the for ! Thank you.
– Joao Peixoto Fernandes