Last answered:

06 Dec 2021

Posted on:

06 Dec 2021

0

Displaying elements from a list on the same row in Python 3?

How to Display elements from a list on the same row in Python 3?

1 answers ( 0 marked as helpful)
Posted on:

06 Dec 2021

0

Please note the following difference between using Python 2 and 3.

Assume you have a list x containing the following four numbers: 10, 20, 30, and 40.



x = [10, 20, 30, 40]

To print all of the 4 elements on a line in Python 2 you have to use the following syntax:



print x,

To obtain the same output in Python 3, you need to execute



print (x, end = “ “)

Submit an answer