Skip to content

Commit

Permalink
Python string count()
Browse files Browse the repository at this point in the history
  • Loading branch information
Pankaj Kumar committed Oct 22, 2018
1 parent 1afcccf commit ecf4e23
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Python-3/basic_examples/strings/string_count.py
@@ -0,0 +1,11 @@
s = 'I like Python programming. Python is Awesome!'

print(f'Number of occurrence of "Python" in String = {s.count("Python")}')

print(f'Number of occurrence of "Python" in String between index 0 to 20 = {s.count("Python", 0, 20)}')

s = input('Please enter a string:\n')

sub = input('Please enter a sub-string:\n')

print(f'Number of occurrence of "{sub}" in the "{s}" is {s.count(sub)}')

0 comments on commit ecf4e23

Please sign in to comment.