. Advertisement .
..3..
. Advertisement .
..4..
Computers are mostly used to store information and extract information from it. Python is one of the most powerful programming languages. We can use Python to get computers to do most routine processes. This blog is all about how we can print Lists in Python.
How Can You Print Lists in Python?
1) Utilize ‘*’ symbol
Utilizing the ‘*’ symbol, you will print a list this way. You will comprehend this better if you see this instance. So let’s have a look at our example.
my_List = ["ITtutoria","IT","tutoria",2020]
print("My List:")
print(*my_List, sep = "\n")
Result:
My List:
ITtutoria
IT
tutoria
2020
2) Utilize for loop
Utilizing the for loop, you may print a list. It is incredibly simple to use. Let’s have a look at an example:
my_List = ["ITtutoria","IT","tutoria",2022]
for i in my_List:
print(i)
Result:
ITtutoria
IT
tutoria
2022
3) Utilize map()
Syntax:
map(function, iterables)
#function:Required
# iterables:Required
Utilizing map(), you may print a list. Let’s have a look at an example:
my_List = ["I","t","t","o","r","i","a"]
print(' '.join(map(str, my_List)))
Result:
I t t o r i a
4) Utilize join()
Syntax:
string.join(iterable)
# iterable:Required
Utilizing join(), you may print a list. Let’s have a look at an example:
my_List = ["ITtutoria:","IT","tutoria"]
print(' '.join(my_List))
Result:
ITtutoria: IT tutoria
Conclusion
Printing Lists in Python is a confusing problem. We hope this blog has helped clear the air around how to do it. If you have more questions about this topic, please comment below. Thank you for reading; we are always excited when one of our posts can provide useful information on a topic like this!
Leave a comment