#🔒 I’m new in the if…else statement thing so I need some help

45 messages · Page 1 of 1 (latest)

eternal raptor
#

print("Welcome to our store where we sell dangerous weapons that can wipe out humanity!")
print("What would you like to buy first?—firearms or explosive gadgets")
Weapons=int(input("Enter your choice of weaponary:"))
if Weapons:firearms
print("We have various selections in this section")

halcyon roverBOT
#

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

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.

minor delta
#

Can you explain what you're trying to do?

eternal raptor
#

This shows when I try to run it

eternal raptor
minor delta
#

do you understand what int means?

eternal raptor
#

Not really

minor delta
#

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

eternal raptor
#

So I should use str?

minor delta
#

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

eternal raptor
#

Got it

#

Now this shows

minor delta
#

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'

eternal raptor
#

Ok

minor delta
#

== 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

eternal raptor
minor delta
#

yes sorry, the line should end with : too

#

if will always end with :

eternal raptor
#

Ok

#

It worked!

#

I appreciate your help man

minor delta
#

np!

eternal raptor
#

Btw are you a moderator or something ?

minor delta
#

Yes I am

eternal raptor
#

I see

#

Well I will be continuing on my program

minor delta
#

Good luck!

eternal raptor
#

Thx

minor delta
# eternal raptor 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

eternal raptor
#

I’m probably gonna need help later but this will close on its own if it’s inactive for too long,right?

eternal raptor
#

Okay

halcyon roverBOT
#
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.