Python Forum

Full Version: Can someone fix this simple code so it works?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I get a syntax error. Here is the code:
gender = raw_input("Whats your gender")
age = (int(raw_input("Whats your age")) 
if gender == female and age >= 18:
    print "good"
else: print "bad"
You should show the error message.
Line 2 is missing closing ) and should be quote around 'female'.
The code is also Python 2.
gender = raw_input("Whats your gender: ")
age = int(raw_input("Whats your age: "))
if gender == 'female' and age >= 18:
    print "good"
else:
    print "bad"
You should of course use Python 3.6 -->,then it look like this.
gender = input("Whats your gender: ")
age = int(input("Whats your age"))
if gender == 'female' and age >= 18:
    print("good")
else:
    print("bad")