Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def count(target, the_list):
- counter = 0
- for item in the_list:
- if item == target_item:
- counter += 1
- return counter
- ##################################################
- scores = []
- for x in range (0, 30):
- scores.append(random.randint(0, 10))
- print(scores)
- target_item = 10
- top_scorers = count(target_item, scores) # Count function called here
- print("{0} learners got top marks".format(top_scorers))
- ##################################################
- pencils = ["red", "orange", "red", "green"]
- target_item = input("What colour pencil are you looking for? ")
- found_pencils = count(target_item, pencils)
- print("{0} of your pencils were found".format(found_pencils))
- ##################################################
Advertisement
Add Comment
Please, Sign In to add comment