0

Is this correct program

gender = male if gender==male: print ("ramesh is a male") elif gender ==female: print ("sita is a female") else: print("ur transgender")

23rd Jan 2024, 11:40 AM
Rajeev Srivastav
Rajeev Srivastav - avatar
2 Answers
+ 2
Rajeev Srivastav there are a couple of issues with the code. 1. Variables male and female are undefined. Possibly you meant to compare them as literal character strings. If so, then the strings should be enclosed in quotation marks (either single or double), like this: "male", "female". 2. Indentation is missing. You must indent lines to indicate which lines belong inside the if and elif clauses. (Since the print statement in the else clause is on the same line, there is no need to indent that one).
23rd Jan 2024, 3:49 PM
Brian
Brian - avatar
+ 1
run the program and see what happens.
23rd Jan 2024, 11:43 AM
Lisa
Lisa - avatar