Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Sequences Sequence Operations Count and Index

Rommel Rodriguez
Rommel Rodriguez
2,548 Points

exactly, does python recognize plurality?

in the tuple example. i understand when you say that exactly and the uppercase does not match however the keyword for the search was "tuple" (which it found one instance, so does python recognize plurals?

4 Answers

Steven Parker
Steven Parker
231,272 Points

Python only matches strings on a character-by-character basis, the words made up by the characters have no meaning to Python directly. It has no idea if the string is singular or plural, or even a word at all.

Sometimes the forms of a word are only different by the addition of one letter (usually "s"), so a string search for the singular form will find it inside the plural, but this is entirely due to character matching individually.

Jonathan Davidson
Jonathan Davidson
1,641 Points

I had the same question, so I played around with the code. It finds characters inside the string as long as the case is the same. So for instance, you could search for 'mut' and it will find it inside immutable. However, if you searched for 'Mut' it would not work. So it's not that python understands the plurality of 'tuples,' it's just finding 'tuple' inside 'tuples.'

marin stefan daniel
marin stefan daniel
5,422 Points

it will find "app" both in "apples" or in "apps" ... it just looks for the letters "app" ... with our example "tuple" and "tuples" it is just a coincidence that it actually is the plural