Print 5 items in a row on separate lines for a list?

前端 未结 11 953
耶瑟儿~
耶瑟儿~ 2021-02-07 19:15

I have a list of unknown number of items, let\'s say 26. let\'s say

list=[\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',
\'i\',\'j\',\'k\',\'l\',\'m\',\'n\',\'         


        
11条回答
  •  一个人的身影
    2021-02-07 19:33

    Just to prove I am really an unreformed JAPH regular expressions are the way to go!

    import re
    q="".join(lst)
    for x in re.finditer('.{,5}',q)
      print x.group()
    

提交回复
热议问题