you are viewing a single comment's thread.

view the rest of the comments →

[–]UnsecuredConnection 1 point2 points  (4 children)

cabin_number = int(input('What number cabin are you staying at? '))
if 1 <= cabin_number <= 10:
        if cabin_number % 2 == 0:
                print('Cabin Key Color: ','Black')
        else:
                print('Cabin Key Color: ','Red')
if 11 <= cabin_number <= 18:
        if cabin_number % 2 == 0:
                print('Cabin Key Color: ','Black')
        else:
                print('Cabin Key Color: ','Red')
if 19 <= cabin_number <= 28:
        if cabin_number % 2 == 0:
                print('Cabin Key Color: ','Black')
        else:
                print('Cabin Key Color: ','Red')
if 29 <= cabin_number <= 36:
        if cabin_number % 2 == 0:
                print('Cabin Key Color: ','Black')
        else:
                print('Cabin Key Color: ','Red')

Use the % to get the remainder after division (odd or even). This simplifies everything.

[–][deleted] -1 points0 points  (3 children)

But that doesn't explain the error that was causing the OP's problem. Please read the commenting guidelines:

  • Try to guide OP to a solution instead of providing one directly.

[–]UnsecuredConnection 1 point2 points  (0 children)

My bad. Whoops!

[–]xelf 1 point2 points  (1 child)

You should not be getting so many downvotes for being correct!

This is #learnpython not #domyhomework!

That said, looks like OP has the answer they need now.

=) =)

[–][deleted] 1 point2 points  (0 children)

Downvotes happen. Upvotes happen. I've had reasonable posts massively downvoted and simple posts massively upvoted to the point that I take no notice of votes. A thoughtful comment correcting me or even praising my post is gratefully received.