def xdgt(x): if x is "m": a = True print(a) else: a = False print(a) x = input("Are you Male or Female? please only input m or f:") xdgt(x) print(a) Result:
Traceback (most recent call last): File "/tmp/sessions/dd8fb527f68c80d1/main.py", line 10, in print(a) NameError: name 'a' is not defined
isto compare strings, use==. In short, your function should be written asreturn x == 'm'.