Member-only story
10 Python Features I Wish I Had Learned Earlier
I ended up spending too much time creating code that would function properly. My mistake was making simple tasks overly complex.
My code would involve using loops to count something, creating temporary variables for exchanging values, and keeping track of index numbers whenever I wanted to loop through a list.
My code was doing everything that it should be doing. I was getting the right output and I could comprehend my code.
However, once I began to discover some of Python’s inbuilt capabilities, I found out that I was solving problems that had already been simplified by Python.
Unfortunately, the worst part was that all these capabilities did not require me to use any packages.
For example, before, I would write something like this:
numbers = [10, 20, 30]
index = 0
for number in numbers:
print(index, number)
index += 1Then I discovered enumerate().
numbers = [10, 20, 30]
for index, number in enumerate(numbers):
print(index, number)Same result. Less code. Less chance for error.
This revelation piqued my curiosity to see what other things I was missing out on.
Here are 10 Python features that I wish I knew about sooner. Some of them will improve…










