17.9k views
1 vote
How could I compare only the 1st letter of strings in the "names" list with the input?

How could I compare only the 1st letter of strings in the "names" list with-example-1
User Adrian S
by
7.9k points

1 Answer

4 votes

So let's say we have the list:

list1 = ["Apple", "Banana", "Cherry"]

If we print this with indexes:
print(list1[0])

It'll show:
Apple

Now, we can add another index like:
print(list1[0][0])

And that'll show
A

User Zumzum
by
7.0k points