diff --git a/challenges/intermediate-empty-tuple/hints.md b/challenges/intermediate-empty-tuple/hints.md new file mode 100644 index 0000000..b863fc3 --- /dev/null +++ b/challenges/intermediate-empty-tuple/hints.md @@ -0,0 +1 @@ +Check out [annotating-tuples](https://docs.python.org/zh-cn/3/library/typing.html#annotating-tuples) diff --git a/challenges/intermediate-empty-tuple/question.py b/challenges/intermediate-empty-tuple/question.py new file mode 100644 index 0000000..2d82c51 --- /dev/null +++ b/challenges/intermediate-empty-tuple/question.py @@ -0,0 +1,14 @@ +""" +TODO: + +foo should accept a empty tuple argument. +""" + + +def foo(x): + pass + + +## End of your code ## +foo(()) +foo((1)) # expect-type-error diff --git a/challenges/intermediate-empty-tuple/solution.py b/challenges/intermediate-empty-tuple/solution.py new file mode 100644 index 0000000..d521c1b --- /dev/null +++ b/challenges/intermediate-empty-tuple/solution.py @@ -0,0 +1,14 @@ +""" +TODO: + +foo should accept a empty tuple argument. +""" + + +def foo(x: tuple[()]): + pass + + +## End of your code ## +foo(()) +foo((1)) # expect-type-error