#๐Ÿ”’ Unable to pass all the test cases

10 messages ยท Page 1 of 1 (latest)

lunar wolf
#

I am trying to understand what I am missing that is failing the test case when num = 0. This is my code:

umbral lynxBOT
#

@lunar wolf

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.

lunar wolf
#
stored_lines = []

skip_next = False

while True:
    line = input('Enter line: ')

    if line == 'END':
        break

    elif skip_next:  
        skip_next = False 
        continue

    elif line == "":
        skip_next = True
        continue

    elif len(line) == num:
        stored_lines.append(line)
    
for stored_line in stored_lines:
    print(stored_line)
umbral lynxBOT
#

Hey @lunar wolf!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
misty nymph
#

elif line == "": is the same as elif len(line) == num: when num is 0, no?

#

if the user input an empty line
does this suggest that the line should be "", or that the line should contain only whitespace?

#

Because the last elif will never trigger in the case of num being 0. The elif before it will trigger, as an empty string has a len of 0.

lunar wolf
umbral lynxBOT
#
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.