inserting characters at the start and end of a string

前端 未结 7 1186
灰色年华
灰色年华 2020-12-02 14:06

I am new and trying to find a way to insert a number of L\'s at the beginning and end of a string. So if I have a string which says

\"where did I put my cupcake thi

7条回答
  •  有刺的猬
    2020-12-02 14:26

    Let's say we have a string called yourstring:

    for x in range(0, [howmanytimes you want it at the beginning]):
        yourstring = "L" + yourstring
    for x in range(0, [howmanytimes you want it at the end]):
        yourstring += "L"
    

提交回复
热议问题