fork download
  1. text = """package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6. queue := make(chan string, 2)
  7. queue <- "one"
  8. queue <- "twoO"
  9. close(queue)
  10. for elem := range queue {
  11. fmt.Println(elem)
  12. }
  13. }"""
  14.  
  15. def get(text, x, y):
  16. try:
  17. return text[x][y]
  18. except IndexError:
  19. return ' '
  20.  
  21. foo = text.splitlines()
  22. maxlen = max(len(line) for line in foo)
  23.  
  24. transpose = '\n'.join(''.join(get(foo,y,x) for y in range(len(foo))) for x in range(maxlen))
  25.  
  26. print(transpose)
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
p i f       }
a m u        
c p n        
k o c        
a r  qqqcf } 
g t muuulo   
e   aeeeor   
  " iuuus    
m f neeeeef  
a m (   (lm  
i t ):<<qet  
n "  =--um.  
    {   e P  
     m""u:r  
     aote=i  
     knw) n  
     eeo rt  
     ("O al  
     c " nn  
     h   g(  
     a   ee  
     n    l  
         qe  
     s   um  
     t   e)  
     r   u   
     i   e   
     n       
     g   {   
     ,       
             
     2       
     )