-
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) .describe("Example") def test_group(): .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
Output:
-
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
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}