How to output vertically in python

(*-*)浩
Release: 2019-07-03 09:43:22
Original
16052 people have browsed it

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
Copy after login

It can be done using a for loop:

for name in "Hello World":
    print(name)
Copy after login

It can also be done using the join method:

print("\n".join("Hello World"))
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template