Given a string, display only those characters which are present at an odd index number. For example, str = "pynative" so you should display ‘y’, ‘a’, ‘i’, ‘e’.
Answers
Answered by
1
Answer:
For printing odd characters, we need to start with characters starting at position 1 with a difference of 2. Slicing operator in this case will be written as str[1::2] . index is initialized to 0. A while loop iterates over the string starting from 0 till the length of string which is calculated using len function.
Similar questions