Home >Backend Development >Python Tutorial >How to output vertically in python

How to output vertically in python

(*-*)浩
(*-*)浩Original
2019-07-03 09:41:3216085browse

Vertically output "Hello World", the entire code does not exceed 2 lines.

How to output vertically in python

Example: The output is as follows(Recommended learning: Python video tutorial)

H
e
l
l
o
 
W
o
r
l
d

It can be done using a for loop:

for name in "Hello World":
    print(name)

It can also be done using the join method:

print("\n".join("Hello World"))

For more Python related technical articles, please visit Python Learn in the tutorial column!

The above is the detailed content of How to output vertically in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn