在第1个n之前打印最后n个行

时间:2017-09-17 06:41:04

标签: python

嘿,我们如何在第一部分之前打印字符串的下半部分,就像字符串是2n行然后写入最后n行,然后是前n行。

例如:

INPUT:

我的名字,

saurabh singh

输出:

saurabh singh

我的名字,

1 个答案:

答案 0 :(得分:0)

如果是2n行,请执行以下操作

temp = str_inp.split("\n")
print(temp[len(temp)/2:] + temp[:len(temp)/2])
相关问题