We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 6: Let's Review
Day 6: Let's Review
Sort by
recency
|
3404 Discussions
|
Please Login in order to post a comment
C# solution
using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) {
string even = ""; // Initialize with empty string string odd = "";
}
n = str(input("What is your name")) a = "" b = "" for x in range(len(n)): if x%2 == 0: a+=n[x] elif x%2 != 0: b+=n[x] print(a+""+b)
This is my code. it gives right output in pycharm but why cant i pass the test cases?/ anyoone please help
Remove this "What is your name". Notice how it will be in the output with every string you input. And yea it does work.
**SUCCESSFULLY COMPLETED THIS PROGRAM ** PLEASE LET ME KNOW, TO OPTIMIZE THIS!!
// import java.io.; import java.util.;
public class Solution {
}
test_cases = int(input()) strings = []
for _ in range(test_cases): strings.append(input())
for item in strings: even_index = item[0:len(item):2] odd_index = item[1:len(item):2] print(even_index,odd_index)
here I Got this output...
Scanner sc=new Scanner(System.in); int n=sc.nextInt(); sc.nextLine(); for (int i = 0; i