#๐Ÿ”’ personal project - needs some help with variables

28 messages ยท Page 1 of 1 (latest)

left fiberBOT
#

@vital mesa

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.

vital mesa
#

when the input for grade is a letter 'z' for example, no error gets raised

sullen spade
#

Pls share code like this:

#

!code

left fiberBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

vocal plume
#

well, the code above was made to use 0 when the grade letter was unrecognized

#

so why is that unexpected?

vital mesa
sullen spade
#

For that you'll need to write

return grade_score[grade.upper()]```
#

your .get function returns a zero if the value isn't found, ValueError is never raised

vital mesa
#

ohhh, thank you very much guys !

sullen spade
#

No problem, just please share code as text next time, not a picture, so we can paste in into an IDE

#

Issues like this one are quickly caught by a good type checker like mypy, this will save us a lot of time on helping

vital mesa
sullen spade
#

type three backticks and "py" in discord, copy your code and paste it, type three more backticks, press enter

#
print("like that")
vital mesa
#

could you help me such that next time i would know how to use it haha, thanks

sullen spade
#

Well, i just pasted your code into the window, clicked paste and everything works

#

Maybe there was a bug or something

vocal plume
vital mesa
#

thank you to the both of you guys for your time

sullen spade
#

No problem!

left fiberBOT
#
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.