teromakotero icon

Count numbers and characters in string

teromakotero | PRO | 05/08/19 08:47:19 PM UTC | 0 ⭐ | 340 👁️ | Never ⏰ | []
Python |

480 B

|

None

|

0 👍

/

0 👎

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