diff --git a/how-to-indent-in-python/README.md b/how-to-indent-in-python/README.md new file mode 100644 index 0000000000..64dec7b6c8 --- /dev/null +++ b/how-to-indent-in-python/README.md @@ -0,0 +1,3 @@ +# How to Properly Indent Python Code + +This folder contains sample code for the Real Python tutorial [How to Properly Indent Python Code](https://realpython.com/how-to-indent-in-python/). diff --git a/how-to-indent-in-python/long_indented_list.py b/how-to-indent-in-python/long_indented_list.py new file mode 100644 index 0000000000..a452066ab1 --- /dev/null +++ b/how-to-indent-in-python/long_indented_list.py @@ -0,0 +1,17 @@ +long_list_of_names = [ + "Amy", + "Brian", + "Carol", + "Dennis", + "Emma", + "Frank", + "Georgia", + "Herbert", + "Isabelle", + "Joshua", + "Kimberly", + "Laurence", + "Megan", + "Nicolas", + "Ophelia", +] diff --git a/how-to-indent-in-python/lucky_number.py b/how-to-indent-in-python/lucky_number.py new file mode 100644 index 0000000000..59897586c0 --- /dev/null +++ b/how-to-indent-in-python/lucky_number.py @@ -0,0 +1,8 @@ +lucky_number = 7 +for number in range(10): + if number == lucky_number: + print("Found the lucky number!") + else: + print(f"{number} is not my lucky number.") + +print("Done.") diff --git a/how-to-indent-in-python/sample_code.py b/how-to-indent-in-python/sample_code.py new file mode 100644 index 0000000000..ffd40abcd8 --- /dev/null +++ b/how-to-indent-in-python/sample_code.py @@ -0,0 +1,12 @@ +# ruff: noqa +def add(a, b): + answer = a + b + + return answer + +def sub (c , + d): + + answer = c -d + + return answer diff --git a/pyproject.toml b/pyproject.toml index 5844cb3150..f70243817e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,8 @@ line-length = 79 exclude = [ ".devcontainers", ".github", - "migrations" + "migrations", + "how-to-indent-in-python/sample_code.py" ] [tool.ruff.lint]