count in python

Posted by Paidboom - 6 months ago

count in python : Python String count() with EXAMPLES

players = [ 'Lokesh Rahul', 'virat kohali', 'rohit shrama', 'sikhar dhavan', 'Lokesh Rahul']
results = players.count('Lokesh Rahul')
print('Lokesh Rahul are :', results)
# define string
string = "Python is awesome, isn't it?"
totaltimeused = "is"
results1 = string.count(totaltimeused)
# print count
print("The count is:", results1)
list1 = [2,3,4,3,10,3,5,6,3,3]
results2 = list1.count(3)
print('The count of element: 3 is ', results2)
#search the substring
list2 = "PHP Python Java Laravel Python Anmgularjs"
str_len=len(list2)
results3 = list2.count("Python", 9 , str_len )
print(results3)