#70303·freeCodeCamp

Travel Weather Planner has incomplete and inaccurate tests and hints

Author: majestic-owl448Created Sep 23, 2026Updated Sep 30, 2026
Labelshelp wantedscope: curriculumpython v9 cert

Describe the Issue

The Build a Travel Weather Planner lab has the following test and hint problems.

  1. Rain-dependent behavior is not distinguished by the tests

    python
    run_case(
        {
            "distance_mi": 2,
            "is_raining": True,
            "has_bike": False,
            "has_car": True,
            "has_ride_share_app": True
        },
        "False"
    )
    python
    run_case(
        {
            "distance_mi": 2,
            "is_raining": False,
            "has_bike": True,
            "has_car": False,
            "has_ride_share_app": False
        },
        "True"
    )
    python
    run_case(
        {
            "distance_mi": 12,
            "is_raining": False,
            "has_bike": False,
            "has_car": False,
            "has_ride_share_app": True
        },
        "True"
    )
    python
    run_case(
        {
            "distance_mi": 12,
            "is_raining": False,
            "has_bike": True,
            "has_car": True,
            "has_ride_share_app": False
        },
        "True"
    )

    Replacing print(has_bike and not is_raining) with print(has_bike) passes all nine behavioral tests, although a rainy two-mile trip with a bike must print False. Independently, replacing the final output with print((has_car or has_ride_share_app) and not is_raining) also passes all nine tests, although rain must not prevent a long trip when a car or ride-share app is available.

    Suggested fix: Add output checks for these combinations, keeping the existing cases:

    distance_mi is_raining has_bike has_car has_ride_share_app Printed result
    2 True True False False False
    12 True False True False True
    12 True False False True True
  2. The boolean-operator requirement is missing from the user stories, and its test accepts other unary operators

    You should use at least one boolean operator (`and`, `or`, or `not`) in your code.

    The user stories require conditional statements and specific outcomes, but never require the and, or, or not keywords. The requirement in this hint should also appear in the user stories so learners know they must use at least one boolean operator.

    The test also accepts arithmetic unary operators:

    python
    bool_ops = [
        node for node in ast.walk(tree)
        if isinstance(node, (ast.BoolOp, ast.UnaryOp))
    ]
    
    assert len(bool_ops) >= 1

    The assertion passes for x = -1, which contains none of the three operators named in the hint. ast.UnaryOp also represents unary plus, unary minus, and bitwise inversion; see the Python AST reference.

    Suggested fix: Add a user story explicitly requiring at least one boolean operator (and, or, or not). Update the test to accept ast.BoolOp or an ast.UnaryOp only when its op is ast.Not:

    python
    bool_ops = [
        node for node in ast.walk(tree)
        if isinstance(node, ast.BoolOp)
        or (isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.Not))
    ]
    
    assert len(bool_ops) >= 1

    Verify that code using and, or, or not passes this test, while code whose only operators are unary minus (-1), unary plus (+1), or bitwise inversion (~1) fails it.

  3. The distance type assertion accepts booleans

    ({ test: () => runPython(`assert isinstance(distance_mi, (int, float))`) })

    The assertion accepts True and False as distances because isinstance(True, (int, float)) evaluates to True. This does not enforce the distinction between a numeric distance and the four boolean flags in the user stories.

    Suggested fix: Exclude booleans from the numeric type check:

    javascript
    ({ test: () => runPython(`assert isinstance(distance_mi, (int, float)) and not isinstance(distance_mi, bool)`) })
  4. Incorrect no/nor construction

    When the distance is greater than `6` miles and no car nor a ride share app is available, the program should print `False`.

    The sentence mixes no with nor and inserts an unmatched article before the second noun.

    Suggested fix: Use the following hint:

    When the distance is greater than 6 miles and neither a car nor a ride-share app is available, the program should print False.

Affected Pages

https://www.freecodecamp.org/learn/python-v9/lab-travel-weather-planner/build-a-travel-weather-planner

Expected behavior

  1. The tests distinguish rainy and dry conditions where they affect the result. A rainy trip between one and six miles prints False even when a bike is available. Trips over six miles print True when a car or ride-share app is available, regardless of rain.
  2. The user stories explicitly require at least one boolean operator (and, or, or not). The test accepts those operators without counting unary plus, unary minus, or bitwise inversion.
  3. The distance type test accepts numeric distances and rejects boolean values.
  4. The final hint uses a grammatical construction to describe the absence of both a car and a ride-share app.

Source: freeCodeCamp/freeCodeCamp