11 Tips And Tricks To Write Better Python Codeby@pragativerma
1,698 reads

11 Tips And Tricks To Write Better Python Code

tldt arrow
EN
Read on Terminal Reader

Too Long; Didn't Read

Python generally use a `for` loop to iterate over an iterable object. But there is an easier and more pythonic way to do this by using `enumerate() instead of a 'for' loop. List comprehension instead of raw for loops is a way to create lists based on the existing lists. It can be used to sort the elements in a sorted list or sequence (tuple, set, frozen set) or collection (frozen set) The syntax of a list comprehension looks like this: 'HackerNoon'

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - 11 Tips And Tricks To Write Better Python Code
Pragati Verma HackerNoon profile picture

@pragativerma

Pragati Verma

Learn More
LEARN MORE ABOUT @PRAGATIVERMA'S EXPERTISE AND PLACE ON THE INTERNET.
react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa