The instructions suggest using list comprehension to convert a string of characters into a list. Why not just use the construtor list() to convert the string to a list. For example, if A=‘velociraptor’, what is wrong with using list(A) to get the desired list. (I realize then we still have to convert this list to indices.)
I assume either calling list() is more computationally intensive, or it has something to do with the portion of code used for debugging at the bottom of the model.
Can anyone tell me why we are not encouraged to use list() ?
Here is what the assignment says:
- Create a list that contains the index numbers associated with each character.
- Use the dictionary
char_to_ix
- You can combine this with the list comprehension that is used to get a list of characters from a string.