|
@@ -0,0 +1,17 @@
|
|
|
+import pytest
|
|
|
+
|
|
|
+def lengthOfLastWord(s: str) -> int:
|
|
|
+ s = s.split()[-1]
|
|
|
+ return len(s)
|
|
|
+
|
|
|
+@pytest.mark.parametrize(
|
|
|
+ "s, expect",
|
|
|
+ [
|
|
|
+ ("Hello World", 5),
|
|
|
+ (" fly me to the moon ", 4),
|
|
|
+ ("luffy is still joyboy", 6)
|
|
|
+ ]
|
|
|
+)
|
|
|
+
|
|
|
+def test_cases(s, expect):
|
|
|
+ assert lengthOfLastWord(s) == expect
|