#๐Ÿ”’ Problem with Equals to command

29 messages ยท Page 1 of 1 (latest)

whole zinc
#

When entering the age "34" it gives me the else command instead of the if command result why could this be?

honest terraceBOT
#

@whole zinc

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.

distant timber
#

int is not equal to string

whole zinc
#

oh really?

distant timber
#

!e

age = int("34")
print(age == "34")
honest terraceBOT
distant timber
#

thats why it goes to else

whole zinc
#

Oh

#

Thats weird since on my laptop the script i wrote looks similar to the one i have on here and it allows me to strip the int

distant timber
#

Just the if statement is comparing the converted int with a string

#

So its a logical error

whole zinc
#

Sorry im new to python

#

but i can send a picture of my other script

#

somehow it works

distant timber
# whole zinc

Yes. Notice the difference of your if statement at line 9 here

whole zinc
#

OH

#

OHHHHH

#

I just realised

#

i apologise

#

Thank you so much

distant timber
#

As I said, nothing wrong with the strip

arctic turtle
distant timber
#

np

honest terraceBOT
#
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.