mercredi 18 décembre 2019

How can I use a while loop with an if statement in python?

I'm trying to write a script that takes in a character (M) OR (F) and returns output as male OR female. I was wondering how I could do this with a while loop. What I have currently is if statements which do not loop back.

gender = input('What is your gender? M/F: ').capitalize()
mGender = ''
if gender == 'M':
   mGender = 'Male'
elif gender == 'F':
   mGender = 'Female'
else:
   #how do I go back to make sure only F/f or M/m were input by the user?

Aucun commentaire:

Enregistrer un commentaire