X Pattern
Write a program to take String if the length of String is odd print X pattern otherwise print INVALID.
Input Format:
Take a String as input from stdin.
Output Format:
print the desired Pattern or INVALID.
Example Input:
edyst
Output:
e t d s y d s e t
SOLUTION:
s=input()
l=len(s)
if(l%2 != 0):
for i in range(0,l):
j=l-i-1
for k in range(0,l):
if(k==i or k==j):
print(s[k],end="")
else:
print(end=" ")
print("")
else:
print("INVALID")
Comments
Post a Comment