#๐Ÿ”’ Line too long

34 messages ยท Page 1 of 1 (latest)

turbid notch
#

How can I make it so the line fits within the parameters? For a project so they're picky

modest oracleBOT
#

@turbid notch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

mild basin
#

just put a break wherever you like; I'd break before the "and"

violet bobcat
#

@turbid notch
I think there are 2 options from what I can see:

for source in routes:
    for destination in routes[source]:
        dest = routes[source][destination]
        if (len(dest) == 1) and (plane in dest):
            ...

or

for ... in ...:
    for ... in ...:
        if(
            len(routes[source][destination]) == 1 and
            (plane in routes[source][destination])
        ):
idle brook
#

lol welcome to my hell. as long as you group stuff by parentheses you can break it up inside the parentheses

#

yeah do that

#

@turbid notch Just pick a specific way you're going to break it up and be consistent.

mild basin
#

use "ruff". Let it decide for you ๐Ÿ™‚

turbid notch
#

alright thank you so much

idle brook
#

yeah good luck

turbid notch
#

one more quick question if that's ok

#

my program gave me this checker

#

and I keep returning with this error

#
def is_valid_flight_sequence(route: RouteDict, codes: list[str]) -> bool:
    """
    Return whether codes in route have adjacent direct flights. 
    
    >>> example_route_dict = flight_example_data.create_example_routes()
    >>> is_valid_flight_sequence(example_route_dict, ['GFN', 'TRO', 'SYD'])
    True
    
    >>> example_route_dict = flight_example_data.create_example_routes()
    >>> is_valid_flight_sequence(example_route_dict, ['GFN', 'TRO', 'JCK'])
    False  
    """
    
    for i in range(len(codes) - 1):
        if codes[i] not in route: 
            return False
        if (codes[i + 1] not in route[codes[i]]):
            return False
        
    return True```
#

Referring to this program

#

but

#

I have no idea what I"m doing wrong

#

oh yea and here is example routes()

#
def create_example_routes() -> RouteDict:
    """Return the RouteDict that should be produced when reading the data
    from create_route_file and including only the airports from
    create_example_airports.

    WARNING: Do NOT change this function.
    """

    return {
        'GFN': {'TRO': ['SF3']},
        'JCK': {'RCM': ['SF3']},
        'RCM': {'JCK': ['SF3']},
        'TRO': {'GFN': ['SF3'], 'SYD': ['SF3', 'DH4']}
    }```
violet bobcat
# turbid notch

This screenshot shows that it expected False and then received that value. Is that an error?

turbid notch
sonic wave
#

you can just use a backslash to move it to the next line

turbid notch
#

but

#

I have no idea what's wrong with it

#

the assignment provided the checker

#

so maybe the checker is bugged out for this one example?

#

it's very annoying tho

violet bobcat
#

It is a bit hard to debug when the value it is saying is being received is the one it is expecting. Are you able to run it manually with the examples they provide to check it?

turbid notch
#

yes I ran the function myself and used the example

#

it returned False

#

very weird

modest oracleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.