Returns true if the sentence is every letter in it is Capital.
It wil also return true if there is no letter inside.
HELLO
IM YELLING
1234
!!
Are examples.
def AmIYelling(input_sentence):
return len([l for l in input_sentence if ((l.isalpha() and l.isupper())or not l.isalpha())]) == len(input_sentence)
test.assert_equals(AmIYelling("HELLO"),True)
test.assert_equals(AmIYelling("YES IM STILL YELLING"),True)
test.assert_equals(AmIYelling("No Im not yelling"),False)
test.assert_equals(AmIYelling("neither now"),False)
test.assert_equals(AmIYelling("BUT I AM NOW!!!!"),True)
test.assert_equals(AmIYelling("1234"),True)
Inside a list of words, return the longest of them.
def getLongestWord(words):
longest = ""
for w in words:
longest = w if len(w) > len(longest) else longest
return longest
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
Test.describe("Tests")
Test.assert_equals(getLongestWord(["word1","word11", "word111"]), "word111", "Regular")
Test.assert_equals(getLongestWord([]),"", "Exceptional cases")
Test.assert_equals(getLongestWord(["word"]),"word","Lenght 1")