Answer to Question #311487 in Python for pranith

Question #311487

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



1
Expert's answer
2022-03-14T17:09:17-0400
# 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 

>>> 


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS