return 문이 모든 테스트 케이스 (빈 문자열이있는 테스트 케이스)를 통과하지 않는다고 생각합니다. @FLOTUS는 언급이 공간으로 진행되거나 짹짹의 시작이되어야하기 때문에 언급이 아닙니다. 대신 빈 문자열로 전달해야합니다. 이 문제를 해결하는 방법에 대한 도움을 주시면 감사하겠습니다!목록에서 요소를 추출 하시겠습니까?
def extract_mentions(tweet):
''' (str) -> list of str
Return a list containing all of the mentions in the tweet, in the order, they appear in the tweet.
Note: This definition of a mention doesn't allow for mentions embedded in other symbols.
Note: This definition of a mention doesn't allow for mentions embedded in other symbols.
>>> extract_mentions('@AndreaTantaros - You are a true journalistic professional. I so agree with what you say. Keep up the great work! #MakeAmericaGreatAgain')
['AndreaTantaros']
>>> extract_mentions('I'm joining @PhillyD tonight at 7:30 pm PDT/10:30 pm EDT to provide commentary on tonight's #debate. Watch it here.')
['PhillyD']
>>> extract_mentions('Join me live in @Springfield, @ohio!')
['Springfield, ohio']
>>> extract_mentions('They endured beatings and jail time. They sacrificed their lives for this [email protected]')
[''] '''
return [tag.strip('@') for tag in tweet.split() if tag.startswith('@')]
're.findall (r '\ B @ \ w +', tweet)'을 사용할 수 없습니까? https://regex101.com/r/jloffB/1 –
마지막 예제가 빈 문자열을 포함하는 목록을 반환해야하는 이유는 무엇입니까? 빈 목록 (모든 (0) 언급 목록)을 반환하지 않아야합니까? –