# -*- coding: utf-8 -*- """ Lab 7, Task 3 Writing functions using loops """ def num_vowels(s): """ returns the number of vowels in a string s consisting of lower-case letters """ count = 0 for c in s: if c in 'aeiou': count += 1 return count def rem_all(elem, vals): """ returns a list in which all occurrences of elem in values have been removed """ result = [] for i in range(len(vals)): if vals[i] != elem: result += [vals[i]] return result def get_pos_int(prompt): """ gets a positive integer from the user based on the input string prompt. This problem lends itself to an indefinite loop because we don't know ahead of time how many repetitions we will need until the user enters a positive integer. """ val = int(input(prompt)) while val <= 0: val = int(input('The input must be positive. Try again: ')) return val