#๐ Having trouble fixing an error. Need Assistance.
22 messages ยท Page 1 of 1 (latest)
@tranquil gate
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.
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
im getting the same message?
@tranquil gate what's the return type of your function
return formatted_list
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
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']]
"""
Hey @tranquil gate!
You are using the wrong character instead of backticks. Use ```, not """.
@zealous laurel im still getting the same error
what did you change
i changed the casing to a capital
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.