Move History

Rooted by: kool kode
Fork Selected
  • Code
    def you_are_cool(n="Taki"):
        if not isinstance(n, str):
            return "Wait, so your name ISN'T a string of text?! That's wild!"
        n = n.strip()
        if not n:
            return "There is no name, so I'm not complimenting you. LOL"
        elif len(n) > 100:
            return "Man, you have an insanely long name! Do people call you by your full name or just a nickname?"
        elif n.isdigit():
            return "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!"
        else:
            return f"Hello {n}, you are very cool!"
        
    # edge case go BRRR
    Test Cases
    import codewars_test as test
    from solution import you_are_cool
    
    # test.assert_equals(actual, expected, [optional] message)
    @test.describe("Example")
    def test_group():
        @test.it("test case")
        def test_case(): 
            test.assert_equals(you_are_cool('tetra-coder'), 'Hello tetra-coder, you are very cool!')
            test.assert_equals(you_are_cool("123!@#"), 'Hello 123!@#, you are very cool!')
            test.assert_equals(you_are_cool("cool"), 'Hello cool, you are very cool!') #cursed
            test.assert_equals(you_are_cool(""), "There is no name, so I'm not complimenting you. LOL")
            test.assert_equals(you_are_cool(123), "Wait, so your name ISN'T a string of text?! That's wild!")
            test.assert_equals(you_are_cool("a" * 101), "Man, you have an insanely long name! Do people call you by your full name or just a nickname?")
            test.assert_equals(you_are_cool("42"), "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!")
            test.assert_equals(you_are_cool("John Doe"), "Hello John Doe, you are very cool!")
    
    # edge case testing go BRRRR
  • Code
    • def you_are_cool(n):
    • def you_are_cool(n="Taki"):
    • if not isinstance(n, str):
    • return "Wait, so your name ISN'T a string of text?! That's wild!"
    • elif n.strip() == "":
    • n = n.strip()
    • if not n:
    • return "There is no name, so I'm not complimenting you. LOL"
    • elif len(n.strip()) > 100:
    • elif len(n) > 100:
    • return "Man, you have an insanely long name! Do people call you by your full name or just a nickname?"
    • elif n.strip().isdigit():
    • elif n.isdigit():
    • return "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!"
    • else:
    • return "Hello " + n.strip() + ", you are very cool!"
    • return f"Hello {n}, you are very cool!"
    • # edge case go BRRR