Home >Backend Development >Python Tutorial >How to output every other character in python

How to output every other character in python

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-25 17:31:426103browse

How to output every other character in python

How does python output every other character? Because there are differences in the output of Python2 and Python3, here we take Python2 and Python3 as examples:

python3: Add the end= ' ' parameter.

python2: End with comma. Two examples are as follows:

>>> a = [1, 2, 3, 4]

Related recommendations: "Python Video Tutorial"

python3 Compilation Environment

>>> for i in a:             
       print(i, end=' ')    
1 2 3 4

python2 compilation environment

>>> for i in a:
       print i,
1 2 3 4

The above is the detailed content of How to output every other character 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