How to write a program to accepts a string from console and print the characters that have even indexes?

Example:

If the following string is given as input to the program:
H1e2l3l4o5
Then, the output of the program should be:
Hello

print("Please enter text to print::")
inputchars = input()

if inputchars:
	string = ""
	for i in inputchars:
		if inputchars.index(i)%2 == 0:
			string += str(i)
	
	print('-------------------')
	print("You Entered:", inputchars)
	print("Result:")
	print(string)
# OUTPUT::
Please enter text to print::
H1e2l3l4o5
-------------------
You Entered: H1e2l3l4o5
Result:
Hello

Leave a Comment