# Define the data on the age and gender of each person
data = [
(23, "Male"),
(35, "Female"),
(18, "Male"),
(40, "Male"),
(29, "Female"),
(17, "Male"),
(32, "Female"),
(45, "Male"),
(25, "Female"),
(19, "Male"),
]
# Initialize the count of males to 0
male_count = 0
# Iterate over the data and count the number of males
for person in data:
if person[1] == "Male":
male_count += 1
# Print the total number of males
print("Total number of males:", male_count)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
# Define the data on the age and gender of each person
data = [
(23, "Male"),
(35, "Female"),
(18, "Male"),
(40, "Male"),
(29, "Female"),
(17, "Male"),
(32, "Female"),
(45, "Male"),
(25, "Female"),
(19, "Male"),
]
# Initialize the count of males to 0
male_count = 0
# Iterate over the data and count the number of males
for person in data:
if person[1] == "Male":
male_count += 1
# Print the total number of males
print("Total number of males:", male_count)