write a prgram to print columns in rows without space in python?
1st input:
3
Not you kid
They are got
Like great
output
NotTheyLike
youaregreat
kidgot
2nd input
4
hy hy
by
hy hy hy
by by hy by hy
output:
hybyhyby
hyhyby
hyhy
byhy
# write a prgram to print columns in rows without space in python?
import numpy as np
s = "Not you kid\nThey are got\nLike great"
print("Input:\n",s)
s = s.split("\n")
res = max(s, key = len)
u = len(s)
v = len(res.split(" "))
t = []
for r in range(0,u):
temp=[]
for c in range(0,v):
temp.append(" ")
t.append(temp)
for r in range(0,u):
temp = s[r].split(" ")
for c in range(0,len(temp)):
t[r][c] = temp[c]
t = np.array(t)
t = np.transpose(t)
print("\nOutput:")
for r in range(0,len(t)):
s = ""
for c in range(0,len(t[r])):
s = s + t[r][c]
print(s)
Python Output
Input:
Not you kid
They are got
Like great
Output:
NotTheyLike
youaregreat
kidgot
>>>
Comments
Leave a comment