Find the maximum length of consecutive 0’s.

In this program, we will take a string as input and find the maximum length of consecutive 0’s in a given binary string.

Steps to solve the program
  1. Take a binary string as input.
  2. Split the binary string on 1 to find the maximum length of consecutive 0’s.
  3. Print the output.
				
					#Input string
string ="10001100000111"

#splitting on 1
list1 = string.split("1")
max_ = (max(list1,key=len))

#Printing output
print(len(max_))
				
			

Output :

				
					5
				
			

remove zeros from an IP address. 

remove all consecutive duplicates of a given string

Leave a Comment