python countteens Given a list of integers return the number
python count_teens
Given a list of integers, return the number of teens (13-19, inclusive).
count_teens([20, 28]) 0
count_teens([29, 20, 19, 15, 6]) 2
count_teens([18, 22, 10, 13, 17, 20]) 3
def count_teens(nums):
| Given a list of integers, return the number of teens (13-19, inclusive).
def count_teens(nums): |
Solution
# def count_teens function
def count_teens(nums):
# initilize count to zero
count = 0
# for each num in nums
for num in nums:
# if number between 13 and 19 increment count
if num>=13 and num<=19:
count+=1;
print count;
count_teens([20, 28])
count_teens([29, 20, 19, 15, 6])
count_teens([18, 22, 10, 13, 17, 20])
\"\"\"
sample output
0
2
3
\"\"\"
![python count_teens Given a list of integers, return the number of teens (13-19, inclusive). count_teens([20, 28]) 0 count_teens([29, 20, 19, 15, 6]) 2 count_tee python count_teens Given a list of integers, return the number of teens (13-19, inclusive). count_teens([20, 28]) 0 count_teens([29, 20, 19, 15, 6]) 2 count_tee](/WebImages/45/python-countteens-given-a-list-of-integers-return-the-number-1141739-1761612543-0.webp)