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

How to output every other character in python

爱喝马黛茶的安东尼
Release: 2019-06-25 17:31:42
Original
6128 people have browsed it

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

Related recommendations: "Python Video Tutorial"

python3 Compilation Environment

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

python2 compilation environment

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

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!

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