Print characters at odd places in a string.

In this program, we will take a string as input and print characters at odd places in a string.

Steps to solve the program
  1. Take a string as input.
  2. Use the range function to find the odd places from the length of the string.
  3. Print only those characters at odd places in a string using Indexing.
				
					#Input string
string = "abcdefg"

for i in range(len(string)):
    if i%2 != 0:
    #Printing output
        print(string[i],end="")
				
			

Output :

				
					bdf
				
			

count the number of consonants in a string.

remove all duplicate characters from a given string

Leave a Comment