this question has answer here:
implement program requests 3 words (strings) user. program should print true if words entered in alphabetical order; otherwise nothing printed.
enter first word: bass enter second word: salmon enter third word: whitefish true since b > s > w, prints true
this have far:
firstwords=input("enter first word: ") secondwords=input("enter second word: ") thirdwords=input("enter third word: ") word=[firstwords,secondwords,thirdwords] print(word) k=word.sort() print(k) if (k==none): print('true') elif (word==k): print("true") somehow cannot store value of word.sort() in k
you sorting word "in place" (i.e. sorts word directly, doesn't return sorted copy) word.sort(). doesn't return useful.
you use k=sorted(word) instead, returns sorted copy , doesn't affect word.
Comments
Post a Comment