0

Help me with my script?

I have created a script which asks you "How many students in your class?", for example i type in 3, it says, "Enter gender of student No." like 1 to the number you entered, you should write f for female m for male, if you write anything else it will start from where you were, if you did student number 2 wrong it will ask you student number 2 again. and finally it says the amount of females and males. and what i want it is to like finally say 1. male 2. female 3. male 4. male and even if you type 100 students it will go to that number. I hope you get what i mean. Thanks! a = int(input("How many students in your class?")) b = str() ttlM = 0 ttlF = 0 StuGndr = [] i = 1 while i <= a: b = input("Enter gender of student No." + str(i)) if (b == "m" or b == "M"): i += 1 ttlM += 1 elif (b == "f" or b == "F"): i += 1 ttlF += 1 else: print("Invalid") print("There are " + str(ttlM) + " males and " + str(ttlF) + " females")

27th Oct 2017, 11:15 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar
4 Answers
+ 4
Cool, now I wanna see it, post it here? so I can see how you solved it?
27th Oct 2017, 12:43 PM
Ipang
+ 3
Well, I tried your code on Code Playground, it works, what help would you ask anyway? I only have one question though, the StuGndr variable, what is the purpose of that, I didn't notice it was used?
27th Oct 2017, 11:31 AM
Ipang
0
Oh im sorry, i was testing something out and i may have forgotten to delete the empty list! and my question is, i want it to lastly say, the genders with numbers, like 1 gender 2 gender 3 gender until the amount of students you entered. Thanks
27th Oct 2017, 11:48 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar
0
i got ittttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
27th Oct 2017, 12:14 PM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar