#๐Ÿ”’ Age between script

63 messages ยท Page 1 of 1 (latest)

ocean spearBOT
#

@misty ferry

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.

main dragon
#

Your comparing int to a string

misty ferry
#

I just realised

#

๐Ÿ˜ญ

#

i accidentally deleted it so if other people are interested in my problem

forest forge
#

can you repost

misty ferry
#

i put the values as string

wintry ore
#

so if age == 0, the person is not a child?

acoustic tundra
#

Well if your age is 0 without any seconds of existence you technically don't exist

main dragon
#

Literally Korea

misty ferry
#

๐Ÿ˜‚

#

i have another problem now

forest forge
misty ferry
#

using the following ages, 0 - 12 - 13 - 18 - 19 do not give me a print command

#

how would i fix this?

forest forge
#

can you send your code

#

oh

main dragon
forest forge
#

are you supposed to be using "" ? those are used for strings no?

lilac trout
#

Aren't they not supposed to print (according to the if statement in the image)?

misty ferry
#

Let me send my script

forest forge
#

thanks

lilac trout
#

And also, make sure you're checking it with an int. if age > 0 etc.

misty ferry
#

the ages 0 - 12 - 13 - 18 and 19 do not give a print

main dragon
forest forge
#

``age = int(input("Age: "))

if age >= 0 and age <=12:
print("Child is what you are")``

lilac trout
#

You don't need the .strip() btw

misty ferry
#

i want it to print

#

Oh!

main dragon
forest forge
#

prints for me

misty ferry
#

huh

lilac trout
main dragon
lilac trout
#

0, 12, 13, 18 and 19 all fail to pass the if statements.

forest forge
#

use the <= >=

misty ferry
lilac trout
#

You might want to consider using <= or >=

misty ferry
#

this is the feedback i get

#

after writing 18

forest forge
lilac trout
#

Those check if it's less than or equal to and if it's greater than or equal to, respectively.

misty ferry
#

i got it to work thank you

#

i used <= and >=

misty ferry
#

ohh okay

#

i understand now

#

ty

lilac trout
#

Using < or > is strictly less than and strictly greater than, so those few numbers wouldn't pass any of the statements.

quaint ocean
#

!e p.s you can chain comparisions to make it more readable like so

age = 8
print(0 <= age <= 12)
ocean spearBOT
misty ferry
#

oh okay so it ignores the number i input

lilac trout
#

0 isn't > 0, but 0 is >= 0

#

So anything equal also passes

wintry ore
#

you could just check age <= 12

#

and skip the lower bound check

#

if someone enters a negative age, the joke's on them

ocean spearBOT
#
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.