Normal Python code equivalent to given list comprehension

0 votes

Can anyone provide the equivalent python code of below list comprehension:
x = [4 * [0] for i in range(3)]

Jun 6, 2018 in Python by george
• 200 points
16 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
You can try this code

list1=[]

for i in range(3):

   list1.append(4*[0])

print(list1)
answered Jun 8, 2018 by jain12
• 160 points

Related Questions In Python

0 votes
1 answer

List comprehension on a nested list - How to do it in Python?

Not sure what your desired output is, ...READ MORE

answered Nov 21, 2018 in Python by Nymeria
• 3,500 points
36 views
+2 votes
11 answers

How to print array/ list without brackets in python?

name=["a","b","c"] print (', '.join(name)) It will simply take all ...READ MORE

answered Apr 18, 2018 in Python by aayushi
• 750 points
11,932 views
0 votes
1 answer

Adding elements to a list in python

Use extend() instead: l = [5, 7, 12, ...READ MORE

answered Apr 23, 2018 in Python by Nietzsche's daemon
• 4,260 points
14 views
0 votes
1 answer

Python - convert string to list

try states.split() this would help. READ MORE

answered Jul 20, 2018 in Python by Priyaj
• 56,120 points
32 views
0 votes
1 answer

Python - convert string to list

states.split() will return ['Alaska', 'Alabama', 'Arkansas', 'American', 'Samoa', ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,570 points
37 views
0 votes
1 answer

How to Print a List in Python

ou are using Python 2.x syntax with ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,710 points
38 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
+4 votes
6 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.