Posts Day06 - Let's Review (Python 3)
Post
Cancel

Day06 - Let's Review (Python 3)

  • URL : https://www.hackerrank.com/challenges/30-review-loop/problem

  • Objective
    • Today we’re expanding our knowledge of Strings and combining it with what we’ve already learned about loops. Check out the Tutorial tab for learning materials and an instructional video!
  • 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 space-separated strings on a single line (see the Sample below for more detail).
  • Note: 0 is considered to be an even index.

  • Input Format
    • The first line contains an integer, T (the number of test cases).
    • Each line i of the T subsequent lines contain a String, S.
  • Constraints
    • 1 <= T <= 10
    • 2 <= lenthofs <= 10000
  • Output Format
    • For each String Si (where 0 <= j <= T - 1 ), print Si’s even-indexed characters, followed by a space, followed by Si’s odd-indexed characters.
1
2
3
4
5
t = int(input())
for i in range(t):
    s = input()
    a, b= s[::2], s[1::2]
    print(a, b)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 3
 hi


h i


 hyunmin


humn yni


 sdjkasld


sjal dksd
This post is licensed under CC BY 4.0 by the author.