I’m new to programming and I’m learning Python, so my question might seem clumsily:
If we have a list (for example, a list of different names) and we want the names that end with a special
letter (for example, a) to be selected and placed in a new list, what should we do?
List1=[ "Sara", "Alex" , "Tina" , "Jack" ]
New_List=[]
for name in List1:
if name[]=="a"
print(New_List)
I mean something like this.
I don’t know what to write exactly to refer to the last index of each name (third line).
line3: for name in list1[]==’a’:
Thank you for your help.
yasaman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.