#๐Ÿ”’ Having trouble fixing an error. Need Assistance.

22 messages ยท Page 1 of 1 (latest)

worthy loomBOT
#

@tranquil gate

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.

serene tiger
#

Looks like it's getting "once upon a python script", when it should be getting "Once upon a python script"

- once upon a python script
+ Once upon a python script
#

Capitalization matters when comparing strings

tranquil gate
#

im getting the same message?

zealous laurel
#

@tranquil gate what's the return type of your function

tranquil gate
#

return formatted_list

zealous laurel
#

try this?

#

hmmmm im not sure actually, i might have to do some testing

#

@tranquil gate did it work?

#

looks like it's working on a test script i wrote

#
def test(test_list: list[str]):
    """A test function

    >>> test([1, 2, 3])  # doctest: +NORMALIZE_WHITESPACE
    [1,
    2]
    """
    return test_list


if __name__ == "__main__":
    import doctest

    doctest.testmod()

gives error

#
def test(test_list: list[str]):
    """A test function

    >>> test([1, 2, 3])  # doctest: +NORMALIZE_WHITESPACE
    [1,
    2, 3]
    """
    return test_list


if __name__ == "__main__":
    import doctest

    doctest.testmod()

doesn't error

tranquil gate
#

def make_book_list(books_text):
"""
Formats a string of book details into a list of lists.
Each inner list contains: [title, price, type, rating].
The title will have only its first character capitalized, matching the function output.

sample_booklist = 'book 1 once upon a python script 31.45 Hardback Cheap book 2 The Java Jungle 27.99 Paperback Average book 3 C++ Chronicles 65.00 Hardback Average'
>>> make_book_list(sample_booklist)
[['Once upon a python script', 31.45, 'Hardback', 'Cheap'],
['The java jungle', 27.99, 'Paperback', 'Average'],
['C++ chronicles', 65.0, 'Hardback', 'Average']]
"""

worthy loomBOT
#

Hey @tranquil gate!

Please edit your message to use a code block

You are using the wrong character instead of backticks. Use ```, not """.

tranquil gate
#

@zealous laurel im still getting the same error

zealous laurel
tranquil gate
#

i changed the casing to a capital

zealous laurel
#

i cannot help you if you do not even read my message

#

sorry

worthy loomBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. 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.