Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)
edited by

Can someone help me rewrite the single line loop to multiple the lines using for loop in python? I am trying to understand how this has formatted.

y = {element: r for element in variables(e)}

1 Answer

0 votes
by (36.8k points)

The dictionary comprehension is equivalent to the below loop:

y = {}

for element in variables(e):

    y[element] = r

Want to be a master in Data Science? Enroll in this Data Scientist

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...