I have successfully managed to get rid of '\n' in a list, but I can't seem to get rid of a blank.
This is what I've done:
from pymystem3 import Mystem
m = Mystem()
user_flash = Flashcard.objects.filter(owner=self.request.user).values_list('question', flat=True)
user_flash_ = [item.replace('\n', ' ') for item in m.lemmatize(" ".join(user_flash))]
But when I try to do the same for "", it doesn't work.
So, before I did anything, the list looked something like: ['word1', '', 'word2', '\n'] After implementing my code above I'm left with: ['word1', '', 'word2'] How can I get rid of that one blank? The following...
user_flash_clean = [item.replace('', ' ') for item in user_flash_]
...didn't work...
I have found a way to circumvent the problem, but it would be nice if it's possible to just get rid of that blank. (Note - I do have a good reason for doing the .join before lemmatizing, but if that is where my problem is coming from, would be happy to explain why I did it so that I can maybe implement a different solution)