Пример #1
0
def isStringInTranslatedList(stringtofind):

    # Fiddled around with having for i in listofwords as well(instead of range(len()), not sure which is better,
    # nor which one I prefer.
    for i in range(len(listofwords)):
        if stringtofind in smooshedmorse(listofwords[i]):
            return listofwords[i]
def test_TranslatedWordListIsOfCorrectLengthIncludingNewLines():
    assert len(smooshedmorse(wordlistasstring)) == 4237061
def test_CanCovertUpperCaseLettersToLowerCaseMorse(test_input, expected):
    assert smooshedmorse(test_input) == expected
def test_CanTranslateLowerCaseWords(test_input, expected):
    assert smooshedmorse(test_input) == expected
Пример #5
0
def isPalindromeInList(palindromelength):
    listofwords = wordlistasstring.split()
    for i in range(len(listofwords)):
        if isPalindrome(smooshedmorse(listofwords[i])) and len(
                listofwords[i]) == palindromelength:
            return listofwords[i]
Пример #6
0
from Smooshed_Morse_Code import smooshedmorse
from Word_List import wordlistasstring


# Function that checks if a string is a palindrome.
def isPalindrome(stringtocheck):
    return stringtocheck == stringtocheck[::-1]


# Function that takes the length of the strings to check as input and returns the first word that is of specified
# length and has a morse translation that is a palindrome.
def isPalindromeInList(palindromelength):
    listofwords = wordlistasstring.split()
    for i in range(len(listofwords)):
        if isPalindrome(smooshedmorse(listofwords[i])) and len(
                listofwords[i]) == palindromelength:
            return listofwords[i]


print(isPalindromeInList(13))
print(smooshedmorse("intransigence"))
Пример #7
0
def translatelist(listtotranslate):
    translatedlist = []
    for i in range(len(listtotranslate)):
        translatedlist.append(smooshedmorse(listtotranslate[i]))

    return translatedlist