1

I want to print all element of list without any loop in python. And i got this on internet. let list = [1, 2, 3, 4, 5] and print(list). But i don't know what this '' doing here.

Ritik Kumar
  • 587
  • 4
  • 16

1 Answers1

0

printing the list using * operator separated by space

a = [1, 2, 3, 4, 5]   
print(*a) 

Output:

1 2 3 4 5

printing the list using * and sep operator

print(*a, sep = ", ") 

Output:

1, 2, 3, 4, 5

print in new line

print(*a, sep = "\n")

Output:

1

2

3

4

5
Eyal Golan
  • 1,761
  • 1
  • 13
  • 21