Question

En Python 2.x, j'écrirait ...

for i in range(5):
    print i,

... pour obtenir des nombres entiers de 0 à 4 imprimé dans la même rangée. Comment faire en Python 3.x, car l'impression est une fonction maintenant?

Était-ce utile?

La solution

Utilisation print(x, end = ' '):

Des notes de version :

Old: print x,           # Trailing comma suppresses newline  
New: print(x, end=" ")  # Appends a space instead of a newline
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top