Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Program to get number of consecutive repeated substring

# Python3 code to demonstrate working of
# Number of repeated substrings in consecution
# Using split() + count() + list comprehension
  
# initializing string
test_str = 'geeksgeeks are geeksgeeksgeeks for all geeks'
  
# printing original string
print("The original string is : " + str(test_str))
  
# initializing K 
K = "geeks"
  
# count() counts repetition
res = [sub.count(K) for sub in test_str.split(' ') if sub.count(K) != 0]
  
# printing result
print("String repetitions : " + str(res))
Comment

PREVIOUS NEXT
Code Example
Python :: function nbYear(p0, percent, aug, p) { let n = 0; while(p0 < p) { p0 = p0 + Math.round(p0 * (percent/100)) + aug; n ++; } return n; } 
Python :: python service linux 
Python :: how to nest try/except statements 
Python :: get forex exchange rates in python 
Python :: python string josin 
Python :: NumPy bitwise_or Code When inputs are Boolean 
Python :: NumPy unpackbits Syntax 
Python :: how to do something daily python 
Python :: main code for bpsk scheme 
Python :: python override inherited method data model constructor 
Python :: geopandas cmap change options 
Python :: penggunaan values di python 
Python :: call a Python range() using range(stop) 
Python :: python special methods list 
Python :: How to use a <ComboboxSelected virtual event with tkinter 
Python :: python extract multiple values from a single cell in a dataframe column using pandas 
Python :: write an empty block python 
Python :: python output 
Python :: corpus.fit(sentences, window=10) 
Python :: how to map url with usernames prefixed 
Python :: Python (cpython 2.7.16) sample 
Python :: containsDuplicate Set Solution 
Python :: ring Creating a Multi-Dimensional Array using List 
Python :: for loop the string from reverse order and skipping last element in string python 
Python :: How to Load Any HuggingFace Model in spaCy 
Python :: python you can think pad baldi 
Python :: python launch ipython from script 
Python :: pip is not recognized as an internal or external command 
Python :: selenium options to remember user 
Python :: add values to pandas plot 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =