#๐ Help
16 messages ยท Page 1 of 1 (latest)
@mystic linden
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.
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
Unfortunately for that's the catch. I must have one in this code as well. But I felt the same when I first did this bs
case score if 700 <= score <= 850: this doesn't quite make sense though
the case would be case 700 <= credit_score <= 850
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?
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
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.