How could I create a Python function that takes
- a string
- an array like this
[0, 0, ... 0](one zero per letter of the alphabet)
and returns
- a new array with with the zeros transformed to ones if their respective character appears in the word.
So if a word has an 'A' or 'a' and the first spot in the array corresponds to 'a', then the output array would have a 1 in its first spot:
[1, ...]
If a word has a 'B' or 'b', then the output array would have a 1 for its second spot. If a word has an 'a' and a 'b', then the output array would have a 1 in the first and second spots:
[1, 1, ...]
And so on. So the string "abba" would result in something like this:
[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Ideally, I would also be able to search for characters not in the alphabet, like ! and ?, too, and just add other bits to the array to represent those characters.
Any help would be welcome! Thanks a ton.