#🔒 I’m new in the if…else statement thing so I need some help
45 messages · Page 1 of 1 (latest)
Hey @eternal raptor!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
@eternal raptor
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.
Hello 👋
Can you explain what you're trying to do?
Hello
do you understand what int means?
Not really
Python uses different "data types" to represent...well...data
int is a data type that represents whole numbers
str is a data type that represents text
So I should use str?
yes, it doesn't quite make sense to python to say "convert 'firearms' into a number"
when you use input(), python will always treat the user's response as str, so if you want it to be str, you don't need to do anything special
so to compare what the user entered with a specific text, you must use ==, and firearms must be in quotation marks because it's a string
if weapon == 'firearms'
Ok
== is the "equality" operator
it checks if two things are equal
weapon isn't in quotes because it's a variable
it doesn't matter what data type is stored in that variable, you'll never use quotes around a variable name
np!
Btw are you a moderator or something ?
Yes I am
Good luck!
Thx
If that's all for now, you can close this thread with !close. Feel free to leave it open though if you have more questions
I’m probably gonna need help later but this will close on its own if it’s inactive for too long,right?
Yeah, after an hour of inactivity
Okay
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.