Python Python Sequences Sequence Operations Count and Index

Rommel Rodriguez
Rommel Rodriguez
1,907 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?

3 Answers

Steven Parker
Steven Parker
205,347 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,634 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
1,732 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