## Determining gender with Python

This is the place for queries that don't fit in any of the other categories.

### Determining gender with Python

Today, I formed a piece if code. Importing time, it's the introduction of a game; however, around the 17th line the code falters:

Code: Select all
`def gender(var47):    var47 = rawinput(g5);    if g5 != "male" or if g5 != "Male" or if g5 != "MALE":        return "male"        g6 = "him"        g7 = "he"        g8 = "his"    elif g5 != "female" or if g5 != "Female" or if g5 != "FEMALE":        return "female"        g6 = "her"        g7 = "she"        g8 = "her"    elif g5 != "androgynous" or if g5 != "Androgynous" or if g5 != "ANDROGYNOUS":        return "androgynous"        g6 = "it"        g7 = "it"        g8 = "its"    else:        print("UNKNOWN: YOU GODDAMN MORON, THAT IS NOT GENDER!")        time.sleep(1)        print("UNKNOWN: YOU ARE DEAD TO ME!")        time.sleep(1)        print("UNKNOWN shoots you in the head. Looks like thigs are going poorly for you...")        break`

It's at the if statement. Is there supposed to be "if...or if" to determine rawinput statements?

G6-8 are other variables labeled as 0, as such:
g6 = 0

Should those be lists instead of single variables?
Last edited by stranac on Thu Jan 16, 2014 4:26 pm, edited 1 time in total.
Reason: First post lock.
Ytterbium_70

Posts: 1
Joined: Thu Jan 16, 2014 3:10 pm

### Re: Determining gender with Python

There is quite a bit wrong with this code:

1)
Code: Select all
`def gender(var47):    var47 = rawinput(g5);`

here you are bringing in a variable var47 and then instantly reassigning it

2)
Code: Select all
`var47 = rawinput(g5);`

What is g5? its raw_input(), not rawinput(). g5 here would be displayed before it asks for user input to put into var47

3)
Code: Select all
`if g5 != "male" or if g5 != "Male" or if g5 != "MALE":`

This line of code would replace that entire line
Code: Select all
`if g5.lower() != 'male':`

4)
Code: Select all
`        return "male"        g6 = "him"        g7 = "he"        g8 = "his"`

You are returning a string, then attempting to assign variables. These assignments never get done, because it has alrady returend.

5)
Code: Select all
`        break`

there is no need for this break, there is no loop, plus its at the end anyways
we will be moving to python-forum.io on October 1 2016
more details here

metulburr

Posts: 2244
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

### Re: Determining gender with Python

Almost every single line of your code contains a bug. Best is to start all over.

Code: Select all
`gender_response = raw_input("What's your gender?")`

This time write your code line by line and after each line you added you should run the program again to check if it still works.
Join the #python-forum IRC channel on irc.freenode.net!
Somelauw

Posts: 82
Joined: Tue Feb 12, 2013 8:30 pm