Advit loves even numbers. Now, he want't to do a small experiment on even numbers, but decided to do it in a different way. He asks the user to enter a string and then prints all the characters at the even position in the given string, separated by a comma. *
Answers
Answered by
1
The following codes have been written using Python.
Once the string has been entered, we create a list to store the characters at the even index position from the string. We use a for loop, an iteration statement used to perform repeated checking. We give the range as (0, len(s) + 1), since index values start from 0 and end at the last length of the string. We check if the index is even/odd using a conditional statement. If it is even, we append [append is a list function used to add elements to a list, one by one.] it to the list that we created earlier. The final output is then printed.
Similar questions
English,
7 days ago
Physics,
7 days ago
Computer Science,
7 days ago
History,
8 months ago
India Languages,
8 months ago
Math,
8 months ago