Exercise 33 

 Write a program in Python that asks the user to enter a string and display the characters of even index. Example for the string s = “Python”, the program returns “Pto”.


# Ask user to type a string s
s = input("type a string s :")

# define and initialize the string that will contain the characters of even index
even = ""

# search through the string s all characters of even index
for i in range(0,len(s)):
if(i%2 == 0):
even = even + s[i]

print("The extracted string that contains the characters of even index is :", even)

Leave a Reply