您的位置:首页 > 编程语言 > Python开发

Python如何以两个字符一行方式输出"Hello World"

2019-03-26 10:34 344 查看
[code]#空格也是字符
def function(string):
s = "";
for n in range(len(string)):
if (n + 1) % 2 != 0:
s = s + string
;
if len(string) == (n + 1):
print(s);
else:
s = s + string
;
print(s);
s = "";
def main():
input_str = 'Hello World';
function(input_str);
main();

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐