입력 텍스트를 Discrete Regional_indicator 이모티콘으로 변환하는 프로그램에서 작업하고 있습니다. 그러나 문제는 "cab"와 같이 단어를 입력하면 " 알파벳". 단어를 입력 할 때 사전 순으로 정렬되지 않도록 프로그램을 변경할 수있는 방법이 있습니까? (난 단지 테스트 목적을 위해 처음 3 개 문자를 프로그램했습니다. 파이썬으로 코딩 3.5 IDLE) 문자는 그 문장에 표시 한 다음이 텍스트를 출력하면, 프로그램이 문장 검사를받는알파벳 순서로 프로그램 인쇄를 중지하는 방법
한마디로import sys
sentence = input("Enter a sentence:")
sentenceLower = sentence.lower()
sentenceList = list(sentenceLower)
sentenceListLength = len(sentenceList)
while sentenceListLength > 0:
if "a" in sentence:
sys.stdout.write(":regional_indicator_a:")
sentenceListLength = sentenceListLength - 1
if "b" in sentence:
sys.stdout.write(":regional_indicator_b:")
sentenceListLength = sentenceListLength - 1
if "c" in sentence:
sys.stdout.write(":regional_indicator_c:")
sentenceListLength = sentenceListLength - 1
Discord에 복사하여 붙여 넣기.
나는 당신이하려는 것을 이해하고 있는지 모르겠다.하지만 나는 아마도 문장에서 문자를 찾는 대신 문장 속의 문자들을 반복하고 싶을 것이라고 생각한다. –
이것은 짧은 시간에 내 머리 속에서 생각해 낼 수있는 가장 효율적인 방법보다 효율적이지 않습니다. –