Count numbers and characters in string
import random
def count(num,scores):
number = num
count = 0
for i in scores:
if(i == number):
count += 1
return count
scores = []
for x in range (0, 30):
scores.append(random.randint(0, 10))
print(scores)
top_scorers = count(10, scores) # Count function called here
print("{0} learners got top marks".format(top_scorers))
string = "Can you find the letters"
print(count('e',string), " letter e's in the string.")
Comments