Generate a random binary string of given length.

In this program, we will generate a random binary string of a given length.

Steps to solve the program
  1. Import the random library to generate random numbers and create an empty string.
  2. Using for loop with range() function and random.randint generates a random binary number of a given length and add it to the empty string.
  3. Print the output.

Output :

Note: Output can be different since the numbers are selected randomly.

sort a string

check if the substring is present in the string or not

Leave a Comment