accept string from user and display even index of that string
Answers
Answered by
3
Answer:
Method 1: Using string slicing Above program reads a string as input and creates a new string with characters at index which are multiples of 2. Expression str[::2] fetches all characters in a string which have an index difference equal to the value supplied at the right starting from the value at the left.
Similar questions
Social Sciences,
28 days ago
CBSE BOARD X,
28 days ago
History,
28 days ago
Computer Science,
1 month ago
Hindi,
1 month ago
CBSE BOARD X,
9 months ago
English,
9 months ago