Вот (почти) правильная программа с моими комментариями:
# The recommended style for Python is to use CamelCase for classes only:
answer = 23
guess = None # An empty tuple () works to, but this makes more sense.
gender = input("Are you a boy, a girl or an alien? ")
# Using gender.lower() means both 'Boy', 'boy', 'BOY' or 'boY' matches:
if gender.lower() == 'boy':
print("Nice!", gender)
# Although you can do it like this too:
if gender in ('girl' or 'Girl'):
print("Prepare do die!", gender)
# But this is *always* true, so it's wrong. I left this bug in intentionally:
if gender == 'alien' or 'Alien':
print("AWESOME my", gender, "friend!")
# 'guess' == answer will always be false. Remove the quotes:
while guess != answer:
# And you forgot to ask for the guess...
guess = int(input("Guess my age? "))
# Indentation matters in Python:
if guess == answer:
print("Yeah, correct!")
elif guess < answer:
print("Too low! try again")
else:
print("too high")
Это приводит к следующему:
Are you a boy, a girl or an alien? Why, yes, I am.
AWESOME my Why, yes, I am. friend!
Guess my age? 20
Too low! try again
Guess my age? 30
too high
Guess my age? q
Traceback (most recent call last):
File "untitled-1.py", line 19, in <module>
guess = int(input("Guess my age? "))
ValueError: invalid literal for int() with base 10: 'q'
Как видите, проверка вашего ввода - хорошая идея. :) Но это следующий шаг.