Dividing a String into n Equal Parts || Python
In this we are going to see a basic program on Dividing a String into n Equal Parts in Python Programming Language.


given_str = input("Enter String : ")
num = int(input("Enter Size Of Partition : "))

len_str = len(given_str)
k=len_str//num

if(len_str % num != 0):
    print("The given string cannot be divided into", num, "equal halves")
else:
    print("The given string after dividing into", num, "equal halves:")
    for i in range(0, len_str, k):
        print(given_str[i:i+k])

# Coded By Dhiraj Shelke

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post