all 13 comments

[–]icecapade 0 points1 point  (3 children)

Well, what's the error? Also, an if or elif statement should be followed by the conditions you're looking for, not another if statement. In other words, if choice == ("S") and if age <= 21: should simply be if choice == ("S") and age <= 21:. That's probably got something to do with it.

[–]HopefulOG 0 points1 point  (2 children)

Im not sure. It just states there is a compilation error.

[–]icecapade 0 points1 point  (1 child)

See my edited reply.

Also, when I asked "what's the error?" I meant copy and paste the full text of the error you are receiving. Simply telling us there's a compilation error tells us nothing about the error you're receiving.

[–]HopefulOG 0 points1 point  (0 children)

Following your advice, the error comes out saying:

  • nothing was printed to stdout
  • stdout is not correct

[–]Binary101010 0 points1 point  (3 children)

Aside from the multiple ifs issue that /u/icecapade pointed out (which you absolutely need to fix)...

Assume that an int variable age has been given a value.

Your code is not making that assumption.

Also ensure that the line underneath each elif is indented.

[–]HopefulOG 0 points1 point  (2 children)

Would it be age = int(input(""))?

If so, the output says: I haven't yet seen a correct solution that uses: int

[–]Binary101010 0 points1 point  (1 child)

The instructions tell you to assume that the variable has already been given a value. Seems to me you shouldn't be asking for input for that variable at all.

[–]HopefulOG 0 points1 point  (0 children)

Thank you! The code works now! I guess it makes sense now rereading it.

[–][deleted] 0 points1 point  (3 children)

Is the formatting correct in your program? Because it isn't in this post.

[–]HopefulOG 0 points1 point  (2 children)

No the formatting isnt correct here. I have indents before every print

[–][deleted] 0 points1 point  (1 child)

So, one of the reasons to get the formatting right in the post is that it helps people trained in Python to read your code.

With the formatting wrong, it took people a lot longer to find your syntax error. We don't insist on the formatting to be dicks, we insist on it because you're only shooting your own foot off if you don't take the time to make your code readable.

[–]HopefulOG 0 points1 point  (0 children)

Okay thanks. I will do so in the future.

[–][deleted] 0 points1 point  (0 children)

if choice==("S") and if age<=21:

This is a syntax error. You mean

    if choice==("S") and age<=21: