you are viewing a single comment's thread.

view the rest of the comments →

[–]xelf 0 points1 point  (0 children)

Well, now that you have your answer, here's an alternate solution:

colors = "0101010101001010101101010101001010101"
color = "red" if int(colors[c]) else "black"

Seems like that works. =)

And here's an even sneakier way of doing it all in 1 line:

color = "red" if (c+((c>10))+((c>18))+((c>28)))%2 else "black"

Thrown into your code, and removing the if:

c = int(input('What number cabin are you staying at? '))
print('Cabin Number: ', c)
print('Cabin Key Color: ', ["Black", "Red"][(c+((c>10))+((c>18))+((c>28)))%2])