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
777 views

1 answer to this question.

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
• 170 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,560 points
1,517 views
+1 vote
12 answers
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
808 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
• 58,020 points
1,007 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,830 points
822 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP