0
How do loop and get the first character of every element in a python list.
Let's say i have a list: mylist = ["apples", "bananas", "mangos"] I know that print(mylist[0][0]) will return the first character of first element ("a"). Now how do i write a loop that will iterate over all elements, and return there first characters. Output should be = "a" , "b", "m"
3 Respostas
+ 4
for i in myList:
print(i[0],end=",")
0
Travon I already know that i can do that, but i need a loop to run over the whole element.
Example:
for i in mylist:
print(i)
This will return every element separately
- 3
I think you should go with this
Mylist([0][0][1][0][2[0])