11 Tips And Tricks To Write Better Python Codeby@pragativerma
2,049 reads

11 Tips And Tricks To Write Better Python Code

tldt arrow
EN
Read on Terminal Reader
Read this story w/o Javascript

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

I am a Software Developer with a keen interest in tech content writing.


Receive Stories from @pragativerma

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!