#๐Ÿ”’ Help

16 messages ยท Page 1 of 1 (latest)

fleet sirenBOT
#

@mystic linden

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.

formal geode
#

your match statement isn't quite setup correctly

#
match credit_score:
    case score if 700 <= score <= 850:
        credit_category = "Good"
    case score if 600 <= score <= 699:
        credit_category = "Fair"
    case _:
        credit_category = "Poor"
#

your variable is credit_score, but you're using score in your cases. I would expect this to error. You also shouldn't be including if as part of this when using cases

#

I wouldn't even bother with match/case here, a simple if/elif would be fine

mystic linden
formal geode
#

case score if 700 <= score <= 850: this doesn't quite make sense though

#

the case would be case 700 <= credit_score <= 850

mystic linden
#
    match credit_score:
        case credit_score if 700 <= credit_score <= 850:
            credit_category = "Good"
        case credit_score if 600 <= credit_score <= 699:
        case credit_score if 600 <= credit_score <= 699:
            credit_category = "Fair"
        case _:
            credit_category = "Poor"```
#

bbeen fixing them hoes

#

๐Ÿ™ appreciate you again any other spots. that would help me fix to that output?

formal geode
#

I don't actually have much experience with python's match/case since it's still fairly new, but as far as I know, you wouldn't use it for this

#

like you would with other languages switch statements

#

turns out I was wrong and you would use an if like this, but you were still using the wrong variable name

fleet sirenBOT
#
Python help channel closed for inactivity

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.