#๐Ÿ”’ Missing blank on practice test

5 messages ยท Page 1 of 1 (latest)

solemn anvil
#

Hi! We had this practice test and I was wondering what the missing blank could be.... here's the code I wrote

def count_members(file: TextIO) -> list[int]:
    """Given an open file containing group information as described above,
    return a list containing the number of people in each group.
    Every group begins with a GROUP # line (where # is the number for that group).
    All member names contain only lower-case letters.
    Precondition:
    - the file has at least one group
    >>> file = open('sample_groups.txt')
    >>> count_members(file)
    [2, 3, 1]
    """
    counts = []
    line = file.readline().strip()
    while line != '':
        group_count = 0
        line = file.readline().strip()
        while line.islower() and 'GROUP' not in line:
            counts.append(group_count)
    return counts

I was wondering about the third final line for the conditions in the while loop. They asked us to fill out the two conditions between the and and I'm not sure if line.islower() is right.

bronze pineBOT
#

@solemn anvil

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.

solemn anvil
#

here is the full question.

bronze pineBOT
#

@solemn anvil

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.