30 Day code challenge-python

Ganesh Uthiravasagam
1 min readMar 13, 2021

--

Day 6 — Let’s Review

Task

Given a string, S, of length N that is indexed from 0 to N-1 , print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line

Sample input and output

Input Format

The first line contains an integer, T(the number of test cases).
Each line i of the subsequent T lines contain a string, S.

Output Format

For each String Sj (where 0≤j≤T-1), print Sj’s even-indexed characters, followed by a space, followed by Sj’s odd-indexed characters.

Solution

Explanation

Line 1: Gets input from the user

Line 2: Loops for the range given by the user

Line 3: Takes string as an input

Line 4: First prints the even indexed letters and then odd indexed letters

Bonus Tip: By default, the input format is a string, if we need it in integer format then we need to specify it as int(input())

See you on day 7

--

--

No responses yet