Im doing an activity to extend my existing code to check for user input and I can't get it to work properly.
- First attempt:
while 5 > appcounter:
StudentGender.append (input(StudentName[namecount]+",Please Enter Student Gender M or F:"))
if StudentGender[appcounter] == "M":
appcounter = appcounter + 1
namecount = namecount + 1
elif StudentGender[appcounter] == "F":
appcounter = appcounter + 1
namecount = namecount + 1
else:
print("Not a valid input")
- Second Try
for Counter in range (ConstNoStudents+1):
try:
StudentGender[Counter] = (input(StudentName[namecount]+",are you Male or Female, Please use M or F:") )
StudentGender[Counter] = "M" or "F" or "f" or "m"
namecount = listcount+1
except:
print("That is not a valid number")
I ideally want it to identify when the user type's something other than M or F in and Get the user to re-enter the value without adding anything extra to the list
StudentGender.