Answers for "how to print list using for loop in python"

0

how to print list using for loop in python

list = [1,"bob",4,"life",5]
# with loop
for i in list:
    print(i)  
>>> 1
bob
4
life
5

x = [print(i) for i in list]
>>> 1
bob
4
life
5

# without loop
print(*list, sep = "\, ")
>>> 1, bob, 4, life, 5

print(' '.join(map(str, list)))
>>> 1 bob 4 life 5
Posted by: Guest on August-06-2021

Code answers related to "how to print list using for loop in python"

Python Answers by Framework

Browse Popular Code Answers by Language