write a function that reutrns true if all letters of a word

write a function that reutrns true if all letters of a word are sorted alphabetically from right to left. If not, return false.

Let\'s call a word a \"downword\" if its letters are alphabetically sorted, case-insensitively, right to left. By this definition, Pond is a downword because d comes before n, which comes before o, which comes before P. So too is pool (as oo does not violate this definition), but lake is not because neither e nor k comes before a alphabetically. Recall from the test that we called a word an \"upword\" if its letters are alphabetically sorted, case-insensitively. left to right. Consider the below implementation in Python of upword, a function that returns True if word (a str) is an upword and False if it is not. Assume that downword is a function (implemented elsewhere) that returns True if word is a downword and False if it is not. def upword(word): return not downword(word) Is this implementation of upword correct? Explain why or why not. Assume now that downword has not (yet!) been implemented elsewhere. Complete the implementation of downword, below. In such a way that it returns True if and only if word (a str) is a downword. Return False if word contains one or more non-alphabetical characters or if the letters in word are not alphabetically sorted, case-insensitively, right to left. def downword(word):

Solution

following is the code of in which  reutrns true if all letters of a word are sorted alphabetically from right to left. If not, return false.

def isInAlphabeticalWord(w):

    word1=sorted(w)

    word2=[]

    for i in w:

        word2.append(i)

    if word2 == word1:

        return True

    else:

        return False

write a function that reutrns true if all letters of a word are sorted alphabetically from right to left. If not, return false. Let\'s call a word a \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site