Python program to print odd length words in a string without using any function

number_of_strings = int(input("How many strings you want to enter? "))
for line in range(number_of_strings):
    string = input("Enter the string: ")
    even_string = ""
    odd_string = ""
    for i in range(len(string)):
        if i%2==0:
            even_string = even_string  + string[i]
        else:
            odd_string = odd_string + string[i]
    print(even_string,odd_string)

Output:

Python program to print odd length words in a string without using any function

Leave a Reply

Your email address will not be published. Required fields are marked *