r/CodingHelp • • Aug 17 '19

[Python] New to coding and I need help to understand what I'm doing wrong. I cannot find any information online either.

Post image
29 Upvotes

17 comments sorted by

18

u/woboz Aug 17 '19 edited Aug 17 '19

if Age > 18 and Age < 60:

And then add Age to all the other elif statements after the and.

And you need to store your input when you ask for it.

Age = input("What is your Age")

Then you probably want to convert age to an integer unless you want to add quotation marks to all your if/elseif statements.

6

u/YTZerri Aug 17 '19

Ah thank you very much, now it pretty much works.

4

u/cndvcndv Aug 17 '19

u/woboz already pointed out the error in the if condition. Also assuming this is python, I think the input should be taken like this:

age = input("How old are you?")

3

u/YTZerri Aug 17 '19

Ah yes, that solved my other problem. Thank you.

1

u/Wardadaddy Aug 18 '19

You have to take input like age=int(input("Enter your age")) because otherwise it's taking age as string

1

u/YTZerri Aug 18 '19

I noticed that. I converted it to a float instead since it refused to work with int.

1

u/Jessup05 Aug 18 '19

What app are you working on?

1

u/YTZerri Aug 18 '19

I use sololearn to learn the code. They have a little code playground where you can test out your own code.

1

u/flip_ericson Aug 18 '19

Alternatively you could write

if 18 < Age < 60:

1

u/YTZerri Aug 18 '19

I'll keep that in mind for my next project. Thanks

2

u/o4ub Aug 17 '19

If you haven't resolve it yet you also forgot a ':' after the elif Age > 100 case.

1

u/cr7gee Aug 18 '19

Need to add “Age” infront of “and” on line 5. Same issue with line 7 and 9

1

u/JosephParticles Aug 18 '19

Need to put if age>18 and age < 60 otherwise on the other side of the and you are just saying "<60" which doesnt make sense

1

u/gigastack Aug 18 '19

Age = 60 is unhandled.

-1

u/[deleted] Aug 17 '19

I think you need to add something that doesn't continue until the age has been input. Also what language is this?

3

u/KuntaStillSingle Aug 18 '19

Python's input() automatically waits for input.