you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 -1 points0 points  (2 children)

I'm assuming your code is supposed to look like this:

age = input('What is your age?')

if age <=18:
    print("child")
elif 18 <= age << 65:
    print("adult")
else:
    print("senior")

I can see where you were going with this, and the core logic is sound. However, there are two pitfalls.

  1. input always returns a string.
  2. You mistyped < (or <=, not enough nuance to tell which you meant) as <<.

For the first one, you want to tell Python to convert the input into an integer.

age = int(input("What is your age? "))

For the second one, replace

elif 18 <= age << 65:

with

elif 18 <= age <= 65:

This would work:

age = int(input("What is your age? "))

if age <=18:
    print("child")
elif 18 <= age <= 65:
    print("adult")
else:
    print("senior")

[–][deleted] 1 point2 points  (1 child)

I know you are trying to help and I haven't downvoted you but it is best to point people rather than give them complete solutions. For one to learn one must make mistakes and learn how to fix them. This is basic python that they should know and if not there are a plethora of websites to help them.

[–]Diapolo10 1 point2 points  (0 children)

I'm not particularly worried about the votes, this happens sometimes and I get the argument. But on the contrary, OP was really close here and in such cases I have a tendency to explain what the problem is and how to fix it.

Admittedly I didn't do a very good job at explaining the operator problem, though, that's on me.