Tirsvad cb53ab7f15
TirSystem/git-workflows: Release / release (push) Skipped
TirSystem/git-workflows: Sync GitHub mirror metadata / sync-metadata (push) Successful in 17s
TirSystem/git-workflows: Publish accepted milestones / publish (push) Successful in 29s
TirSystem/git-workflows: Publish wiki / publish-wiki (push) Successful in 38s
TirSystem/git-workflows: Validate / validate (push) Successful in 35s
TirSystem/git-workflows: OpenGrep / opengrep (push) Successful in 1m35s
Merge pull request 'Add the framework baseline: gateway MIL-001, wiki, README, licence statement' (#7) from mil-001-baseline into main
2026-11-15 10:33:16 +01:00
2026-11-15 17:30:27 +08:00
2026-10-04 16:33:54 +02:00

🐞 Debugging

Day 13 of Udemy's 100 Days of Code: Python Pro Bootcamp: finding and fixing bugs in Python code.

📚 Table of Contents

🧭 Overview

All exercises live in src/main.py, each commented out with the fix noted beside it. Uncomment one at a time to run it.

Exercises

Exercise Bug Fix
Describe the Problem range(1, 20) never reaches 20, because the upper bound is excluded Use range(1, 21)
Reproduce the Bug dice_imgs[dice_num] raises IndexError when the roll is 6 Index with dice_num - 1
Play Computer A birth year of exactly 1994 matches no branch Use >= in the elif
Fix the Errors input() returns a string, so age > 18 fails; the print is not indented Convert with int(); indent the print
Print is Your Friend == compares instead of assigning, so word_per_page stays 0 Use =
Use a Debugger b_list.append(new_item) sits outside the loop, so only the last item is kept Indent it into the loop

Debugging approach

  1. Describe the problem in your own words.
  2. Reproduce the bug.
  3. Play computer: step through the code by hand.
  4. Fix the errors the interpreter reports.
  5. Use print() to inspect values.
  6. Use a debugger to step through execution.

📋 Requirements

Python 3.

🛠️ Setup

No installation is needed: the exercises use only the Python standard library. Clone the repository and run the program from its root.

▶️ Run

python src/main.py

🧪 Tests

The project has no automated tests. Check that the exercise file compiles:

python -m py_compile src/main.py

📄 License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE.

📎 Appendix: Project documents

The documents a newcomer needs, in reading order.

Document What it tells you
Business Case Why the project exists, its scope and success criteria
Stakeholder Analysis Who is involved; the stakeholder IDs used for owners and reviewers
Project Plan The gateways and their schedule
Milestones One document per gateway: Go/No-Go criteria and tasks
Artifact registry Where each artifact type lives, the next version, the PO language and domain
Traceability matrix How the artifacts link and when each was last reviewed

S
Description
Day 13 of 100 Days of Code (Python): debugging exercises - describe the problem, reproduce the bug, play computer, print and the debugger.
Readme AGPL-3.0
101 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 100%