Posted on Leave a comment

Freelance Developer Hourly Rate By Regions and Professions

What’s the hourly rate of a freelance developer? If you’re like me, you want to peek into the potential of a given profession before you commit years of your life to any profession like freelance developing.

The average freelance developer worldwide earns $56 per hour with conservative estimates ranging as low as $31 and aggressive estimates ranging as high as $82.

The following table compares the hourly rates of employed developers and freelance developers in different regions:

Job Description Status Region Hourly Rate
Web Developer Employee US $31.62
Employee UK £19.29
Freelancer $34.78
PHP Developer Employee US $46.28
Employee UK £20.51
Freelance $50.90
.Net Developer Employee US $55.06
Employee UK £19.29
Freelance $60.56
Python Developer Employee US $56.90
Employee UK £29.79
Freelance $62.59

About the Data. Our data is based on various online sources such as indeed.com, neuvoo.co.uk, and other portals where professionals can report their earnings. We state the sources below in the image captions.

We modified the expected earnings of a freelancer by increasing the average earnings of an employed professional by 10%. This is based on the findings of this study: the average freelancer earns about 10% more than his employed counterpart. We found that in practice, the difference is often much higher than that—freelancers earning much more than employees. One of the reasons may be that freelancers have more control of their earnings—an ambitious freelancer tends to earn a higher percentage more than an ambitious employee in the same profession. This is because there are no caps in freelance earnings.

If you want to earn your full-time income working in your part-time freelancing business, check out our course “Become a Python Freelance Developer”.

Freelance Developer Hourly Rate US

The average hourly rate of an employed web developer is $31.62 per hour in the US. The average hourly rate of a freelance web developer is $34.78 in the US.

The average hourly rate of an employed Python developer is $56.90 per hour in the US. The average hourly rate of a freelance Python developer is $62.59 in the US.

The average hourly rate of an employed PHP developer is $46.28 per hour in the US. The average hourly rate of a freelance PHP developer is $50.90 in the US.

The average hourly rate of an employed .Net developer is $55.06 per hour in the US. The average hourly rate of a freelance .Net developer is $60.56 in the US.

The hourly rates in Canada are similar to the hourly rates in the US.

Freelance Developer Hourly Rate UK

The average hourly rate of an employed web developer is £19.29 per hour in the UK. The average hourly rate of a freelance web developer working remotely is £24.35 in the UK.

The average hourly rate of an employed Python developer is £29.79 per hour in the UK. The average hourly rate of a freelance Python developer working remotely is £48.21 in the UK.

The average hourly rate of an employed PHP developer is £20.51 per hour in the UK. The average hourly rate of a freelance PHP developer working remotely is £39.12 in the UK.

The average hourly rate of an employed .Net developer is £19.29 per hour in the UK. The average hourly rate of a freelance .Net developer working remotely is £46.68 in the UK.

For a freelance developer working in the UK, it’s usually the most profitable strategy to work remotely in the US and earn higher US salaries in the UK.

Freelance Developer Hourly Rate Germany

The hourly rate of a freelance developer in Germany is between 41€ and 83€ per hour. This is an average range that is valid for freelance web developers, Python developers, .Net developers, and PHP developers.

Freelance Developer Hourly Rate India

The hourly rate of a freelance developer in India is between $15 and $50 an hour on average. This depends on the particular skill sets—if you’re skilled in a specialized niche and have worked for more than 2-4 years as a freelance developer, you can usually land higher-paid gigs in the US and reach average freelance developer rates of $61-81 per hour.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Freelance Developer Hourly Rate By Regions and Professions first appeared on Finxter.

Posted on Leave a comment

[Formula] How Much to Charge for a Project? For Freelance Developers & Clients

Problem: How to estimate the price of a given code project as a freelancer and as a client?

Estimating the price of a freelance software project is a common problem for both freelance developers and clients. On freelancing platforms such as Upwork, clients must associate a realistic price to their freelance project. On freelancing platforms such as Fiverr, freelancers must find a reasonable price for the different gigs they offer. In any case, either freelancers or clients must set the right expectations, or negative ratings and disappointments are guaranteed. This is hardly a great business strategy.

So, how to estimate the price for a given software project?

In this tutorial, I’ll give you a simple step-by-step formula to determine the price. But take it with a grain of salt—finding the sweet spot is seldomly as simple as following a formula. Yet, I found that this formula helped many FINXTER freelancing professionals and course students.

You can watch me elaborate on these concepts in the following short YT video as you go over the article:

Here are the three steps summarized:

  • Step 1: Find Business Value B and Multiply It With Your Confidence C to Obtain Expected Business Value B * C.
  • Step 2: Adapt the Expected Business Value by Market Factors +/-50%.
  • Step 3: Price Negotiations and Modifications to Obtain Range between Freelancer’s and Client’s Estimates.

Let’s see what’s behind these steps in the remaining article.

Step 1: Find Your Expected Business Value

Many people tend to start with their hourly rates. Especially beginner freelancers fall into this trap. They’re used to getting paid by the hour as employees. But nothing can be further from the truth if you’re entering the business arena.

Rule: You are getting paid by the value you deliver and not by the number of hours you put in.

If you understand this one rule, you’ll thrive as a freelance developer. If you don’t understand it, you’ll struggle badly.

It’s often easier for clients to absorb this rule—which is why I recommend that every freelancer hires other freelancers from time to time.

As a client, you simply cannot pay more to a freelancer than he’s providing you with value. Even if you wanted—you couldn’t pay $10,000 for a website if the business value of this website is only $10 per month. Well, some clients will do it but it cannot be the foundation of a solid freelancing business. Clients and businesses think in terms of Return on Investment. They want to see tangible results or they won’t pay you adequately.

For you as a freelance developer, you need to figure out how to deliver huge business value in a very short time. If you can solve this one problem, you’ll become very, very rich.

Let’s dive into three project examples:

  • Project 1: Fix a bug of a web app where every day of downtime costs the company $100,000. In this case, the estimated business value is $100,000 if you think you can fix it quickly. You can charge $10,000 for a quick fix within a day and the company will gladly do it—even if it costs you only a few hours to do so.
  • Project 2: Write a web application selling services to 10,000 customers per month with an average customer lifetime value of $100. If you can be sure to deliver this with your web application, you could charge $1,000,000 for this app and the company would get their investment back within a month. However, you can never be sure so you need to add a significant margin of safety. Let’s charge them $50,000 for the reasonable probability of achieving this business outcome.
  • Project 3: Write a small Python script that scrapes data from a website and stores it in an Excel file. The client will save, say, 1h every week due to your script so 52h per year. Every saved hour is worth, say, $10 for the client. The business value is 52h * $10/h = $520 per year. If you charge $300 for the script, the client can justify it.

You see that you must use common sense to estimate the business value. It’s a highly imprecise measure but over time, you’ll develop a knack for it. In many cases, your intuition is just about right.

Note that the business value is completely independent of the time it took to finish the gig. Some clients may need 12 months to create the app for Project 2 which leads to a yearly income of $50,000 before taxes. Other clients may need only one month to create the same app which leads to a monthly income of $50,000. I’m not exaggerating—there are 10x differences, even 100x differences in the efficiency of which freelancers finish projects.


Action step: Find your starting point—the expected business value of the project. Multiply this number with a probability value that reflects how sure you are that the business value will happen in practice.

For example, the business value of your project may be $10,000 and it has a 50% success probability. The starting point of your estimation is $10,000 * 50% = $5,000. This is your expected business value.

Step 2: Adapt the Expected Business Value by Market Factors

The expected business value completely ignores the reality of the market and your specific skills. You need to incorporate this! However, you can never deviate too much from the expected business value because you’ll either become unprofitable or you won’t find clients on a fair-value exchange basis.

  • If you sell your skills far above expected business value, you’ll have too few clients and client acquisition will be a game of luck and hope. This
  • If you sell your skills far below expected business value, you’re likely to become unprofitable and clients will not appreciate your value.

Therefore, you adapt the expected business value only by +/-50% at most. You simply answer the following five questions to come up with your adaptation percentage.

  • Skill: Are you a highly skilled-specialist for this specific gig (+10%), average-skilled (+0%), or below-average (-10%)?
  • Communication: Do you show a positive mental attitude (+10%), a normal attitude (+0%), or a negative mental attitude (-10%)?
  • Experience: Have you finished many similar gigs (+10%), only a few (+0%), or none at all (-10%)?
  • Hourly Rate: Have you earned in previous gigs an hourly rate above the industry average (+10%), at average (+0%), or below-average (-10%)?
  • Speed: Can you guarantee faster than average delivery of the gig (+10%), normal (+0%), or slower than average delivery (-10%)?

These five factors are some of the most important when it comes to perceived value delivery. As a freelancer, you should be able to quickly estimate all of them. As a client, you must evaluate the freelancer regarding these factors.


Action step: Go throw all five factors and adapt your expected business value by the resulting percentage.

For example, the project with expected business value of $5,000 delivered by a freelancer who is highly skilled (+10%), very communicative (+10%), experienced (+10%), with a proven record of a high hourly rate(+10%), and promising fast delivery (+10%) can charge +50% more. The resulting gig estimate would be $7,500.

Step 3: Price Negotiations and Modifications

The resulting gig estimate from the previous step can be justified by both the client and the freelancer. Both will receive expected value if both agree on these factors. Be transparent and let the client or the freelancer on the other side know about your estimations and your assumptions. Show them this method and let them state their opinions. Together, you’ll quickly see which factors are likely to be substantially different than assumed. By being open minded and talking about these factors, you’ll become a better freelancer and a better client because you can adapt your perception of the market place to the reality.

Don’t be strict about the gig estimate but take it as a reasonable starting point. If you receive new data and new assumptions from the other party, incorporate them in this method to obtain a new estimate. The resulting estimate should be a win-win. The freelancer wins profitable business and the client realizes a profitable investment. This is the basis on which a healthy long-term business relationship can flourish.


Action step: Summarize your calculations and assumptions and share them with the other party. Ask them for their estimations. Find common ground.

For example, the project with an expected business value of $5,000 delivered by a freelancer who is highly skilled (+10%), very communicative (+10%), experienced (+10%), with a proven record of a high hourly rate(+10%), and promising fast delivery (+10%) can charge +50% more. The resulting gig estimate would be $7,500.

However, the client may not agree with these percentages and proposes an adaptation percentage of only +30% while the expected business value is only $4,000. Based on this, the client’s gig estimate would be $4,000 * 1.3 = $5,200. The true gig estimate will lie anywhere within [$5,200 and $7,500]. Be open-minded as a client and as a freelancer because a long-term healthy relationship is worth far more than tweaking out the best immediate gig estimate.


Do you want to develop the skills of a well-rounded Python professional—while getting paid in the process? Become a Python freelancer and order your book Leaving the Rat Race with Python on Amazon (Kindle/Print)!

Leaving the Rat Race with Python Book

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post [Formula] How Much to Charge for a Project? For Freelance Developers & Clients first appeared on Finxter.

Posted on Leave a comment

Best Programming Languages to Start Freelancing in 2020

The demand for programming talent has steadily increased in the preceding decades.

In fact, there never has been a better time to start learning to code. Why? Because you (yes, YOU!) can sell your skills for top dollars—the average freelancer earns much more than $100,000 per year (source).

Nobody denies two transformative trends:

  • Programming is on the rise. With the proliferation of computing into every area of our lives, it’s now more important than ever before to be able to speak the language of computers.
  • Freelancing is on the rise. The biggest freelancing platforms such as Upwork or Fiverr grow double-digit year after year. They are out to disrupt the organization of the world’s talents—and it looks like they’re succeeding.

If you combine these trends, you end up with one of the greatest opportunities of our times: freelance developmentthe act of selling your programming services to a global client base.

Do you want to develop the skills of a well-rounded Python professional—while getting paid in the process? Become a Python freelancer and order your book Leaving the Rat Race with Python on Amazon (Kindle/Print)!

Leaving the Rat Race with Python Book

But there are many fundamentally different programming languages, which language to learn? What’s the best language with the highest potential and the biggest growth opportunities?

This article answers this question for you. But instead of going over the different programming languages, I’ll go over the different end-goals you want to achieve. The programming languages will then naturally emerge from your overall goals as a programmer. You should decide on your life goals first and not on the technologies. Otherwise, you end up confused, unmotivated, and unable to see the big picture.

Before you start diving into the details, here’s a quick tabular overview:

Title Best Programming Languages Yearly Income (Average US)
Web Developer JavaScript + HTML + CSS + SQL $78,088
Mobile Developer Android Java $126,154
Mobile Developer Apple Swift $123,263
Back End Developer Python + Django + Flask $127,913
Front End Developer JavaScript + HTML + CSS $109,742
Full-Stack Engineer Python + JavaScript + HTML + CSS + SQL $112,098
Data Scientist Python + Matplotlib + Pandas + NumPy + Dash $122,700
Machine Learning Engineer Python + NumPy + Scikit-Learn + TensorFlow $145,734

Let’s dive into the different freelance developer career choices for maximum success!

Web Developer? JavaScript + HTML + CSS + SQL

Do you want to become a web developer? The most common four programming languages you must learn are JavaScript, HTML, CSS, and SQL. Have a look at the most popular programming languages used by the largest websites in the world: Google, Facebook, and YouTube. They all use JavaScript and HTML as front-end technologies. In the back-end, there are different choices—but a proficient understanding of SQL is a must.

The average salary for a web developer is $78,088 per year in the US:

Mobile Developer Android? Java

Do you want to become a developer for mobile Android apps? The recommended programming language for native Android apps is Java.

The average salary for an Android developer is $126,154 per year in the US:

Mobile Developer Apple? Swift

Do you want to become a mobile developer for Apple apps? The best programming language is Swift which is Apple’s own creation. I’d generally not recommend to lock in your knowledge to a single company but if you’re really committed, it can be a great way to differentiate your skills.

The average salary of a mobile app developer in the US is $123,263.

Back End Developer? Python + Django + Flask

No online business can thrive without a scalable back-end. The servers must run properly and serve a varying number of users. Becoming a back end developer is not the most popular choice—because many people want to “see” the applications they’re coding. This makes back end development a great career choice: less competition and massive value for companies.

The average back end developer earns $127,913 per year in the US.

Front End Developer? JavaScript + HTML + CSS

Developing beautiful, well-rounded front-ends of modern web applications is fun and a prestigious activity that will usually be valued very highly by clients that hire you as a front end freelance developer. The standard languages in front end development are, of course, JavaScript, HTML, and CSS. You must master these languages above everything else! And if you do, you’ll build yourself a powerful skill on which you can base your whole career.

The average front end developer earns $109,742 per year in the US.

Full-Stack Engineer? Python + JavaScript + HTML + CSS + SQL

The most advanced coders in web development are called “full stack engineers”. They have experience in front end and back end development. They know different technologies through years of experience and practice. They have honed their skills to a very high level. To become a full-stack engineer, your best programming language choice is JavaScript, HTML, CSS for the front end and Python and SQL for the back end. But it doesn’t stop there—much more languages must be learned as you go along and move beyond average full-stack programming level.

The average full-stack engineer earns healthy $112,098 per year in the US.

Data Scientist? Python + Matplotlib + Pandas + NumPy + Dash

Do you want to join the ranks of data scientists—often being called “the sexiest professions in the 21st century”? Your best shot is Python and its great libraries: Matplotlib, Pandas, NumPy, and Dash. A great starting point is our book “Coffee Break NumPy”—check it out if you want to become a skilled data scientist with attractive pay and plenty of freelancing opportunities in the years to come!

The average data scientist earns a staggering $122,700 per year in the US. If you become a data engineer (next level), you’ll even reach an average earning level of $130,000.

Machine Learning Engineer? Python + NumPy + Scikit-Learn + TensorFlow

The highest earning potential as a freelance developer comes with the title “Machine Learning Engineer”. As such a developer, you must analyze and create high-performing machine learning models. It’s vital that you understand the background maths and concepts. The most popular programming languages as a machine learning engineer are Python and its powerful libraries NumPy, Scikit-Learn, and TensorFlow.

The average earnings as a machine learning engineer is $145,734 per year in the US. And this is average! It’s hard to find anything better.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Best Programming Languages to Start Freelancing in 2020 first appeared on Finxter.

Posted on Leave a comment

Top 14 Places to Find Remote Freelance Developer Gigs and Work From Home

COVID-19 has changed the world in a sustainable way. Suddenly, even the most conservative bosses realized that it is perfectly efficient to allow developers to work from home. Remote work may easily be one of the most transformative trends in the 21st century: It will have an impact on almost every conventional job under the sun—and the year-over-year double-digit growth of freelancing platforms such as Upwork and Fiverr proves this point.

This article helps you to identify the best places to look for work-from-home, remote freelancing jobs—with a focus on jobs or gigs in the attractive programming sector. The average freelancer earns $51-$61 per hour and, thus, it may be an attractive way for you to build a second income stream besides your main job income.

So, without any further introduction, let’s dive into the top places to look for freelancing gigs! Here’s a quick overview of all gigs—ordered by relevance for freelance developers:

  1. TopTal Developers
  2. StackOverflow Jobs
  3. Hacker News Jobs
  4. GitHub Jobs
  5. Finxter Freelancer
  6. PeoplePerHour Developer Jobs
  7. Authentic Jobs
  8. Vue Jobs
  9. Remote Leads
  10. Redditors For Hire
  11. WeWorkRemotely
  12. Upwork
  13. Fiverr
  14. Twitter Company Remote Jobs

ALL LINKS OPEN IN A NEW TAB!

1. TopTal Developers

TopTal Developers

2. StackOverflow Jobs

Stackoverflow Jobs

3. Hacker News Jobs

Hacker News Jobs

4. GitHub Jobs

Github Jobs

5. Finxter Freelancer

Finxter Freelancer Course

6. PeoplePerHour Developer Jobs

People Per Hour Developer

7. Authentic Jobs

Authentic Jobs

8. Vue Jobs

Vue Jobs

9. Remote Leads

Remote Leads

10. Redditors For Hire

11. WeWorkRemotely

WeWorkRemotely

12. Upwork

Upwork

13. Fiverr

14. Twitter Company Remote Jobs

Twitter Remote Jobs

What Are The Best Freelancing Sites for Coders? Video Lesson

Want to become a freelance developer earning six-figures? Check out the FINXTER Python freelancer course—the world’s most in-depth Python freelancer program!

The post Top 14 Places to Find Remote Freelance Developer Gigs and Work From Home first appeared on Finxter.

Posted on Leave a comment

Python Reverse List with Slicing — An Illustrated Guide

Summary: The slice notation list[::-1] with default start and stop indices and negative step size -1 reverses a given list.

Python Reverse List with Slicing

Problem: Given a list of elements. How to reverse the order of the elements in the list.

Example: Say, you’ve got the following list:

['Alice', 'Bob', 'Carl', 'Dora']

Your goal is to reverse the elements to obtain the following result:

['Dora', 'Carl', 'Bob', 'Alice']

Slicing with Default Start and Stop Values

Slicing is a concept to carve out a substring from a given string.

Use slicing notation s[start:stop:step] to access every step-th element starting from index start (included) and ending in index stop (excluded).

All three arguments are optional, so you can skip them to use the default values (start=0, stop=len(lst), step=1). For example, the expression s[2:4] from string 'hello' carves out the slice 'll' and the expression s[:3:2] carves out the slice 'hl'. Note that slicing works the same for lists and strings.

You can use a negative step size (e.g., -1) to slice from the right to the left in inverse order. Here’s how you can use this to reverse a list in Python:

# Reverse a List with Slicing
names = ['Alice', 'Bob', 'Carl', 'Dora']
names = names[::-1]
print(names)
# ['Dora', 'Carl', 'Bob', 'Alice']

Python masters know slicing from the inside out. Do you want to improve your slicing skills? Check out my book “Coffee Break Python Slicing” that will make you a slice pro in no time!

Alternatives Reversing List

Alternatively, you can also use other methods to reverse a list.

  • list.reverse() — Best if you want to reverse the elements of list in place.
  • list[::-1] — Best if you want to write concise code to return a new list with reversed elements.
  • reversed(list) — Best if you want to iterate over all elements of a list in reversed order without changing the original list.

The method list.reverse() can be 37% faster than reversed(list) because no new object has to be created.

Try it yourself in our interactive Python shell:

Exercise: Run the code. Do all methods result in the same reversed list?

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Python Reverse List with Slicing — An Illustrated Guide first appeared on Finxter.

Posted on Leave a comment

How to Remove Duplicates From a Python List While Preserving Order?

To remove duplicates from a Python list while preserving the order of the elements, use the code list(dict.fromkeys(list)) that goes through two phases: (1) Convert the list to a dict using the dict.fromkeys() function with the list elements as keys and None as dict values. (2) Convert the dictionary back to a list using the list() constructor. As dictionaries preserve the order of the keys, the list ordering is preserved.

Problem: How to remove duplicates from a Python list while keeping the order of the list elements preserved?

You may find this question a little awkward. What has removing duplicates to do with preserving the order of the elements? The reason is simple: a well-known and efficient way to remove duplicates from a list is to convert the list to a set—which is duplicated-free—and converting it back to a list. Here’s what you may find everywhere:

lst = [42, 42, 'Alice', 'Alice', 1]
dup_free = list(set(lst))
print(dup_free)
# ['Alice', 42, 1]

The back-and-forth conversion list(set(lst)) removes all duplicates from the list. However, it doesn’t preserve the order of the elements. In the example, the string 'Alice' now appears before the integer 42.

So, how to remove duplicates while preserving the order of the elements?

Remove Duplicates From List Preserve Order Python

The most Pythonic and blazingly fast approach is to use a dictionary:

lst = [3, 3, 22, 22, 1]
result = list(dict.fromkeys(lst))
print(result)
# [3, 22, 1]

The dict.fromkeys() method creates a new dictionary using the elements from an iterable as the keys. Python dictionary keys are unique by default so converting our list into a dictionary will remove duplicates automatically. Once this has been done with our initial list, converting the dictionary back results in the duplicate-free list.

This is the most Pythonic way to remove duplicates from a Python list while preserving the order.

Is this method fast? Like sets, dictionaries use hash tables, which means they are extremely fast.

Do you want to develop the skills of a well-rounded Python professional—while getting paid in the process? Become a Python freelancer and order your book Leaving the Rat Race with Python on Amazon (Kindle/Print)!

Leaving the Rat Race with Python Book

Do Python Dictionaries Preserve the Ordering of the Keys?

Surprisingly, the dictionary keys in Python preserve the order of the elements. So, yes, the order of the elements is preserved. (source)

Countless online resources like this argue that the order of dictionary keys is not preserved. They assume that the underlying implementation of the dictionary key iterables uses sets—and sets are well-known to be agnostic to the ordering of elements. But this assumption is wrong. The built-in Python dictionary implementation in cPython preserves the order.

Here’s another example:

lst = ['Alice', 'Bob', 'Bob', 1, 1, 1, 2, 3, 3]
dic = dict.fromkeys(lst)
print(dic)
# {'Alice': None, 'Bob': None, 1: None, 2: None, 3: None}

You see that the order of elements is preserved so when converting it back, the original ordering of the list elements is still preserved:

print(list(dic))
# ['Alice', 'Bob', 1, 2, 3]

However, you cannot rely on it because any Python implementation could, theoretically, decide not to preserve the order (notice the “COULD” here is 100% theoretical and does not apply to the default cPython implementation).

If you need to be certain that the order is preserved, you can use the ordered dictionary library. In cPython, this is just a wrapper for the default dict implementation.

Source Article: How to Remove Duplicates From a Python List?

Removing Duplicates From Ordered Lists For Older Versions

Dictionaries only became ordered in all Python implementations when Python 3.7 was released (this was also an implementation detail of CPython 3.6). 

So, if you’re using an older version of Python, you will need to import the OrderedDict class from the collections package in the standard library instead:

 from collections import OrderedDict lst = [1, 1, 9, 1, 9, 6, 9, 7] result = list(OrderedDict.fromkeys(lst))

The output is the following duplicate-free list with the order of the elements preserved:

 print(result) # [1, 9, 6, 7]

Interactive Code Shell

Let’s try this method in our interactive Python shell:

Exercise: Run the code. Does it work?

You can find more ways to remove duplicates while preserving the order in this detailed blog article:

Related tutorial: Python List: Remove Duplicates and Keep the Order

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post How to Remove Duplicates From a Python List While Preserving Order? first appeared on Finxter.

Posted on Leave a comment

Freelance Developer Net Worth

What is the net worth of a freelance developer? In this article, you’ll learn the expected net worth of a freelance developer as a rough estimate.

Definition net worth: Net worth is the value the assets a person or corporation owns, minus the liabilities they owe. It is an important metric to gauge a company’s health and it provides a snapshot of the firm’s current financial position. (source)

The net worth of a freelance developer who earns the average $134,400 per year and saves 10% per year in a low-cost S&P500 index fund is $204,192 after 10 years, $687,592 after 20 years, and $4,541,140 after 40 years. Under these assumptions, a freelance developer with a savings rate of 20% reaches $1,000,000 net worth in year 18. An alternative measurement stick is a simple P/E valuation based on which the expected net worth of a freelance developer would be approximately 10x earnings which is $1,344,000.

Let’s see how we developed these numbers based on realistic assumptions and averaged statistics over millions of US workers.

To come up with a meaningful figure, we’re going for a few assumptions:

Assumptions

  • We assume a US-based freelance developer. Most non-US freelancers can approximate the net worth and earning potential of a US-based freelance developer by using freelancing platforms such as Upwork and Fiverr to participate in the US economy.
  • We assume that the freelance developer has average skills earning the average hourly rate of a Python developer of $56 per hour. The average Python developer worldwide earns $56 per hour (fluctuations between $51 and $61). This statistic is based on five credible online sources including the US government. You can learn more about the hourly rate here.
  • Based on a conservative estimation, your income as a Python freelancer will be $134,400 per year assuming a normal workday of eight billed hours per day for 300 days per year.
  • We assume that the freelancer has a saving rates of 10%. The average savings rate in the US has been between 7% and 17% during the COVID-19 crisis:
Source: Statista
  • We further assume that the saved money is invested in a low-cost index fund generating the 100-y historic return of 9% after fees. (source)

Calculation Net Worth Freelance Developer

Let’s see how the net worth of a freelancer would progress over a period of 50 years based on these assumptions.

So, if you start with age 20, you’d have an $11,000,000 net worth at age 70—quite a legacy! Here’s the yearly table:

Years Future Value (9.00%) Total Contributions
Year 0 $0.00 $0.00
Year 1 $13,440.00 $13,440.00
Year 2 $28,089.60 $26,880.00
Year 3 $44,057.66 $40,320.00
Year 4 $61,462.85 $53,760.00
Year 5 $80,434.51 $67,200.00
Year 6 $101,113.62 $80,640.00
Year 7 $123,653.84 $94,080.00
Year 8 $148,222.69 $107,520.00
Year 9 $175,002.73 $120,960.00
Year 10 $204,192.98 $134,400.00
Year 11 $236,010.34 $147,840.00
Year 12 $270,691.27 $161,280.00
Year 13 $308,493.49 $174,720.00
Year 14 $349,697.90 $188,160.00
Year 15 $394,610.71 $201,600.00
Year 16 $443,565.68 $215,040.00
Year 17 $496,926.59 $228,480.00
Year 18 $555,089.98 $241,920.00
Year 19 $618,488.08 $255,360.00
Year 20 $687,592.01 $268,800.00
Year 21 $762,915.29 $282,240.00
Year 22 $845,017.66 $295,680.00
Year 23 $934,509.25 $309,120.00
Year 24 $1,032,055.09 $322,560.00
Year 25 $1,138,380.05 $336,000.00
Year 26 $1,254,274.25 $349,440.00
Year 27 $1,380,598.93 $362,880.00
Year 28 $1,518,292.84 $376,320.00
Year 29 $1,668,379.19 $389,760.00
Year 30 $1,831,973.32 $403,200.00
Year 31 $2,010,290.92 $416,640.00
Year 32 $2,204,657.10 $430,080.00
Year 33 $2,416,516.24 $443,520.00
Year 34 $2,647,442.70 $456,960.00
Year 35 $2,899,152.54 $470,400.00
Year 36 $3,173,516.27 $483,840.00
Year 37 $3,472,572.74 $497,280.00
Year 38 $3,798,544.28 $510,720.00
Year 39 $4,153,853.27 $524,160.00
Year 40 $4,541,140.06 $537,600.00
Year 41 $4,963,282.67 $551,040.00
Year 42 $5,423,418.11 $564,480.00
Year 43 $5,924,965.74 $577,920.00
Year 44 $6,471,652.65 $591,360.00
Year 45 $7,067,541.39 $604,800.00
Year 46 $7,717,060.12 $618,240.00
Year 47 $8,425,035.53 $631,680.00
Year 48 $9,196,728.72 $645,120.00
Year 49 $10,037,874.31 $658,560.00
Year 50 $10,954,723.00 $672,000.00

After only 24 years working as a freelance developer, you’ll become a millionaire! Note that this graphic doesn’t talk about inflation which could reduce your pace by 2-3% per year. On the other hand, inflation will probably also cause your yearly earnings to rise. Also, you could probably increase your savings rate as you earn more and more through investments. Together, these two factors may balance out.

The same discussion must be made about the development of your skills. In this simulation, we assume that your skills remain average all your life. In my experience, you can reach this average skill relatively quickly after 4-5 years focused effort. You can check out my detailed Python freelancer program to learn how you can accelerate the process towards your thriving freelance developing business online. So, your earnings will probably grow over the years which makes it easier and easier to save more and more money over time.

Related video:

Note that with 20% savings rate (which is possible for most people), you’d reach your goals much earlier:

With a savings rate of 20%, you can reach the $10 million mark already after 40 years and the $1 million mark after 18 years.

Years Future Value (9.00%) Total Contributions
Year 0 $0.00 $0.00
Year 1 $26,880.00 $26,880.00
Year 2 $56,179.20 $53,760.00
Year 3 $88,115.33 $80,640.00
Year 4 $122,925.71 $107,520.00
Year 5 $160,869.02 $134,400.00
Year 6 $202,227.23 $161,280.00
Year 7 $247,307.68 $188,160.00
Year 8 $296,445.38 $215,040.00
Year 9 $350,005.46 $241,920.00
Year 10 $408,385.95 $268,800.00
Year 11 $472,020.69 $295,680.00
Year 12 $541,382.55 $322,560.00
Year 13 $616,986.98 $349,440.00
Year 14 $699,395.81 $376,320.00
Year 15 $789,221.43 $403,200.00
Year 16 $887,131.36 $430,080.00
Year 17 $993,853.18 $456,960.00
Year 18 $1,110,179.96 $483,840.00
Year 19 $1,236,976.16 $510,720.00
Year 20 $1,375,184.02 $537,600.00
Year 21 $1,525,830.58 $564,480.00
Year 22 $1,690,035.33 $591,360.00
Year 23 $1,869,018.51 $618,240.00
Year 24 $2,064,110.17 $645,120.00
Year 25 $2,276,760.09 $672,000.00
Year 26 $2,508,548.50 $698,880.00
Year 27 $2,761,197.86 $725,760.00
Year 28 $3,036,585.67 $752,640.00
Year 29 $3,336,758.38 $779,520.00
Year 30 $3,663,946.64 $806,400.00
Year 31 $4,020,581.83 $833,280.00
Year 32 $4,409,314.20 $860,160.00
Year 33 $4,833,032.48 $887,040.00
Year 34 $5,294,885.40 $913,920.00
Year 35 $5,798,305.08 $940,800.00
Year 36 $6,347,032.54 $967,680.00
Year 37 $6,945,145.47 $994,560.00
Year 38 $7,597,088.56 $1,021,440.00
Year 39 $8,307,706.53 $1,048,320.00
Year 40 $9,082,280.12 $1,075,200.00
Year 41 $9,926,565.33 $1,102,080.00
Year 42 $10,846,836.21 $1,128,960.00
Year 43 $11,849,931.47 $1,155,840.00
Year 44 $12,943,305.31 $1,182,720.00
Year 45 $14,135,082.78 $1,209,600.00
Year 46 $15,434,120.23 $1,236,480.00
Year 47 $16,850,071.05 $1,263,360.00
Year 48 $18,393,457.45 $1,290,240.00
Year 49 $20,075,748.62 $1,317,120.00
Year 50 $21,909,446.00 $1,344,000.00

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Freelance Developer Net Worth first appeared on Finxter.

Posted on Leave a comment

How to Get the Last Element of a Python List?

Problem: Given a list. How to access the last element of this list?

Example: You have the list ['Alice', 'Bob', 'Liz'] and you want to get the last element 'Liz'.

Quick solution: Use negative indexing -1.

friends = ['Alice', 'Bob', 'Liz']
print(friends[-1])
# Liz

To access the last element of a Python list, use the indexing notation list[-1] with negative index -1 which points to the last list element. To access the second-, third-, and fourth-last elements, use the indices -2, -3, and -4. To access the n last elements of a list, use slicing list[:-n-1:-1] with negative stop index -n and negative step size -1.

Method 1: Access the Last Element with Negative Indexing -1

To bring everybody on the same page, let me quickly explain indices in Python by example. Suppose, you have list ['u', 'n', 'i', 'v', 'e', 'r', 's', 'e']. The indices are simply the positions of the characters of this string.

(Positive) Index 0 1 2 3 4 5 6 7
Element ‘u’ ‘n’ ‘i’ ‘v’ ‘e’ ‘r’ ‘s’ ‘e’
Negative Index -8 -7 -6 -5 -4 -3 -2 -1

Positive Index: The first character has index 0, the second character has index 1, and the i-th character has index i-1.

Negative Index: The last character has index -1, the second last character has index -2, and the i-th last character has index -i.

Now, you can understand how to access the last element of the list:

friends = ['Alice', 'Bob', 'Liz']
print(friends[-1])
# Liz

But how to access the second-last element? Just use index -2!

friends = ['Alice', 'Bob', 'Liz']
print(friends[-2])
# Bob

Method 2: Access the n Last Elements with Slicing

But what if you want to access the n last elements? The answer is slicing.

The default slicing operation list[start:stop:step] accesses all elements between start (included) and stop (excluded) indices, using the given step size over the list. For example, the slicing operation friends[0:3:2] would start with the first element 'Alice' and end with the third element 'Liz' (included), but taking only every second element due to the step size of 2—effectively skipping the second element 'Bob'.

You can use slicing with negative start and stop indices and with negative stop size to slice from the right to the left. To access the n last elements in the slice, you’d therefore use the following code:

universe = ['u', 'n', 'i', 'v', 'e', 'r', 's', 'e'] # Access the n=4 last element from the list:
n = 4
print(universe[:-n-1:-1])
# ['e', 's', 'r', 'e']

There are different points to consider in the code:

  • You use a negative step size -1 which means that you slice from the right to the left.
  • If you don’t provide a value for start, stop, or step indices, Python takes the default ones. For example, we don’t provide the start index and perform negative slicing so Python starts from the last element 'e'.
  • You want to get the n last elements. The n-th last element has index -n. But as the stop index is never included in the slice, we need to slice one step further to the left—to the element with index -n-1 to include the element with index -n.

Try this yourself in our interactive code shell:

Exercise: What happens if the list has less than n characters?

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post How to Get the Last Element of a Python List? first appeared on Finxter.

Posted on Leave a comment

How To Update A Key In A Dictionary In Python If The Key Doesn’t Exist?

Summary: To update a key in a dictionary if it doesn’t exist, you can check if it is present in the dictionary using the in keyword along with the if statement and then update the key-value pair using subscript notation or update() method or the * operator. Another workaround for this is, using the setdefault(key[, default]) method which updates the dictionary with the key-value pair only if it doesn’t exist in the dictionary otherwise, it returns the pre-existing items.

Problem: Given a dictionary; how to update a key in it if the key does not exist?

Example:

device = { "brand": "Apple", "model": "iPhone 11",
} < Some Method to Check if key-value pairs "color" : "red" and "year" : 2019 exists or not and then update/insert it in the dictionary > print(device)

Output:

{'brand': 'Apple', 'model': 'iPhone 11', 'color': 'red', 'year': 2019}

To solve our problem statement, let us follow a modular approach and break down our discussion in this article into three parts.

  1. In the first section let us discuss the methods to update or insert a key,
  2. In the second section, we shall be discussing the methods to check if the key is present in the dictionary,
  3. Finally, we shall merge our concepts to reach the final solution.

Without further delay let us dive into the solutions right away.

Section 1: Insert/Update A Key In A Dictionary

Method 1: Create A New Key-Value Pair Assign It To Dictionary | Subscript Notation

We can create a new index key and then assign a value to it and then assign the key-value pair to the dictionary. Let us have a look at the following program which explains the syntax to create a new key-value pair and assign it to the dictionary:

device = { "brand": "Apple", "model": "iPhone 11",
} device["year"] = 2019
print(device)

Output:

{‘brand’: ‘Apple’, ‘year’: 2019, ‘model’: ‘iPhone 11’}

Method 2: Use The update() Function

The update() method is used to insert or update a specific key-value pair in a dictionary. The item to be inserted can also be another iterable. Also, if the specified key is already present in the dictionary then the previous value will be overwritten.

The following code demonstrates the usage of the update() method:

device = { "brand": "Apple", "model": "iPhone 11",
} device.update({"year" : 2019})
print(device)

Output:

{'brand': 'Apple', 'model': 'iPhone 11', 'year': 2019}

Method 3: Using The * Operator

We can combine an existing dictionary and a key-value pair using the * operator. Let us have a look at the following code to understand the concept and usage of the * operator to insert items in a dictionary.

device = { "brand": "Apple", "model": "iPhone 11",
}
device = {**device,**{"year":2019}}
print(device)

Output:

{'brand': 'Apple', 'model': 'iPhone 11', 'year': 2019}

Disclaimer: In the above methods if we do not check the presence of a key in the dictionary, then the value will be overwritten in the dictionary if the key and value are already existing in the dictionary. Now, that brings us to the second section of our discussion!

Section 2: Check If A Key Is Present In A Dictionary

Method 1: Using The in Keyword

The in keyword is used to check if a key is already present in the dictionary. The following program explains how we can use the in keyword.

device = { "brand": "Apple", "model": "iPhone 11", "year":2018
} if "year" in device: print("key year is present!")
else: print("key year is not Present!") if "color" in device: print("key color is present!")
else: print("key color is not present!") 

Output:

key year is present!
key color is not present!

snake unicode Note: Just like the in keyword, we can use the not in keyword to check if the key is not present in the dictionary.

Method 2: Using keys() Function

keys() is an inbuilt method that extracts the keys present in a dictionary and stores them in a list. Thus with the help of this inbuilt method, we can determine if a key is present in the dictionary.

Let us have a look a the following program to understand how to use the keys() method and check the availability of a key in the dictionary:

device = { "brand": "Apple", "model": "iPhone 11", "year":2018
} if "year" in device.keys(): print("key year is present!")
else: print("key year is not Present!") if "color" in device.keys(): print("key color is present!")
else: print("key color is not present!") 

Output:

key year is present!
key color is not present!

Method 3: Using has_key() Function

If you are using Python 2.x then you might fancy your chances with the has_key() method which is an inbuilt method in Python that returns true if the specified key is present in the dictionary else it returns false.

Caution: has_key() has been removed from Python 3 and also lags behind the in keyword while checking for the presence of keys in a dictionary in terms of performance. So you must use avoid using it if you are using Python 3 or above.

Now let us have a look at the following program to understand how we can use the has_key() method:

device = { "brand": "Apple", "model": "iPhone 11", "year":2018
} if device.has_key("year"): print("key year is present!")
else: print("key year is not Present!") if device.has_key("color"): print("key color is present!")
else: print("key color is not present!") 

Output:

key year is present!
key color is not present!

Phew!!! Now, we are finally equipped with all the procedures to check as well as update a key in a dictionary if it does not exist in the dictionary. That brings us to the final stages of our discussion where we shall combine our knowledge from section 1 and section 2 to reach the desired output.

Update Key In Dictionary If It Doesn’t Exist

Solution 1: Using Concepts Discussed In Section 1 and Section 2

Since we are through with the concepts, let us dive into the program to implement them and get the final output:

device = { "brand": "Apple", "model": "iPhone 11",
} # Method 1 : Create a New Key_Value pair and check using the in keyword
if "color" not in device: device["color"] = "red" # Method 2 : Use update() method and check using the not in keyword
if "year" not in device.keys(): device.update({"year" : 2019}) # Method 2 : Use * operator and check using the not in keyword
if "brand" not in device.keys(): device.update({"brand" : "Samsung" })
else: print(device)

Output:

{'brand': 'Apple', 'model': 'iPhone 11', 'color': 'red', 'year': 2019}

Solution 2: Using setdefault() Method

setdefault() is an inbuilt Python method which returns the value of a key if it already exists in the dictionary and if it does not exist then the key value pair gets inserted into the dictionary.

Let us have a look at the following program which explains the setdefault() method in python:

device = { "brand": "Apple", "model": "iPhone 11", "color": "red"
} device.setdefault('year',2019)
print(device)

Output:

{'brand': 'Apple', 'model': 'iPhone 11', 'color': 'red', 'year': 2019}

Conclusion

I hope after reading this article you can check and update values in a dictionary with ease. In case you have any doubts regarding Python dictionaries, I highly recommend you to go through our tutorial on Python dictionaries.

Please subscribe and stay tuned for more interesting articles!

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post How To Update A Key In A Dictionary In Python If The Key Doesn’t Exist? first appeared on Finxter.

Posted on Leave a comment

List Changes After Assignment — How to Clone or Copy It?

Problem: If you assign a list object to a new variable using new_list = old_list, any modification to new_list changes old_list. What’s the reason for this and how can you clone or copy the list to prevent this problem?

Example: Let’s consider the following example.

old_list = ['Alice', 'Bob', 'Carl']
new_list = old_list
new_list.append(42)
print(old_list)
# ['Alice', 'Bob', 'Carl', 42]

Appending an element to the new_list also modifies the original list old_list. Thus, old_list has now four elements—even though you didn’t change it directly.

Explanation

This problem of simultaneously modifying “two” lists arises because you don’t have two lists but only a single one.

In Python, everything is an object. You create a new list object ['Alice', 'Bob', 'Carl'] that resides in your machine’s memory. Both variable names new_list and old_list point to the same object in memory—if you modify one, you also modify the other!

List Changes After Assignment -- How to Clone or Copy It?

The following interactive tool visualizes the memory used by the Python interpreter when executing this particular code snippet:

Exercise: Visualize how the problem arises by clicking “Next”.

Do you understand the source of the problem? Great, let’s dive into the solutions starting with a short overview!

Solution Overview

You can see all three solutions discussed in this tutorial in our interactive Python shell:

Exercise: Change the original list. Do all three methods still produce the same output?

Next, you’ll learn about each method in greater detail!

Method 1: Slicing

The easiest way to create a shallow copy of a Python list is via slicing:

# Method 1: Slicing
old_list = ['Alice', 'Bob', 'Carl']
new_list = old_list[:]
new_list.append(42)
print(new_list)
# ['Alice', 'Bob', 'Carl']

The slicing operation old_list[:] creates a new list, so the variables new_list and old_list now point to different objects in memory. If you change one, the other doesn’t change.

This is the way with the least amount of characters and many Python coders would consider this the most Pythonic one. If you want to learn more about slicing, watch the following video and dive into the detailed blog tutorial.

Related Tutorial: Introduction to Slicing in Python

Method 2: Copy

An alternative is to use the list.copy() method that creates a shallow copy of the list.

# Method 2: Copy
old_list = ['Alice', 'Bob', 'Carl']
new_list = old_list.copy()
new_list.append(42)
print(old_list)
# ['Alice', 'Bob', 'Carl']

The list.copy() method copies all list elements into a new list. The new list is the return value of the method. It’s a shallow copy—you copy only the object references to the list elements and not the objects themselves.

The result is the same as the slicing method: you have two variables pointing to two different list objects in memory.

You can learn more about the list.copy() method in my detailed blog tutorial and the following video:

Related Tutorial: Python list.copy() [Ultimate Guide]

Method 3: List Comprehension

A third way to solve the problem of two lists pointing to the same object in memory is the list comprehension way to create new lists.

# Method 3: List Comprehension
old_list = ['Alice', 'Bob', 'Carl']
new_list = [x for x in old_list]
new_list.append(42)
print(old_list)
# ['Alice', 'Bob', 'Carl']

List comprehension is a compact way of creating lists. The simple formula is [expression + context].

  • Expression: What to do with each list element?
  • Context: What elements to select? The context consists of an arbitrary number of for and if statements.

You can watch the tutorial video and read over the related blog article to learn more about it!

Related Tutorial: An Introduction to List Comprehension

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post List Changes After Assignment — How to Clone or Copy It? first appeared on Finxter.