Computer Science

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. To access the last element of a Python list, use the indexing notation list[-1] with negative index -1 which …

How to Get the Last Element of a Python List? Read More »

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. Appending an element to the new_list also modifies the original …

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

Freelance Developer Skills

This article is an excerpt of my detailed tutorial “The Complete Guide to Freelance Developing” on this FINXTER blog. We’ll answer the following question: What skills do you need to succeed as a freelance developer? Teaching many freelancing students, I have come to learn that most don’t believe they have all the skills they need …

Freelance Developer Skills Read More »

26 Freelance Developer Tips to Double, Triple, Even Quadruple Your Income

There’s a reason why programmers, software developers, and hackers never seem to go out of vogue: Leverage. A skilled programmer may spend a year writing software which, in turn, automates the jobs performed by thousands of workers. Soon will a program for automated driving destroy billions of today’s and tomorrow’s jobs in the logistics sector. …

26 Freelance Developer Tips to Double, Triple, Even Quadruple Your Income Read More »

56 Python One-Liners to Impress Your Friends

This is a running document in which I’ll answer all questions regarding the single line of Python code. It’s based on my interactive collection here but without the slow videos and embedded code shells. Let’s get started! Python One Line If Else You can use a simple if statement in a single line of code. …

56 Python One-Liners to Impress Your Friends Read More »

Python One Line Dictionary

Python’s dictionary data structure is one of the most powerful, most underutilized data structures in Python. Why? Because checking membership is more efficient for dictionaries than for lists, while accessing elements is easier for dictionaries than for sets. In this tutorial, you’ll learn how to perform four common dictionary operations in one line of Python …

Python One Line Dictionary Read More »

Python Import Error (ModuleNotFoundError)

Python’s ImportError (ModuleNotFoundError) indicates that you tried to import a module that Python doesn’t find. It can usually be eliminated by adding a file named __init__.py to the directory and then adding this directory to $PYTHONPATH. If this file (__init__.py) is in the folder, change the position of the import in the file that is …

Python Import Error (ModuleNotFoundError) Read More »

Python Unicode Encode Error

Summary: The UnicodeEncodeError generally occurs while encoding a Unicode string into a certain coding. Only a limited number of Unicode characters are mapped to strings. Thus, any character that is not-represented / mapped will cause the encoding to fail and raise UnicodeEncodeError. To avoid this error use the encode(utf-8) and decode(utf-8) functions accordingly in your …

Python Unicode Encode Error Read More »

[Dash + Flask] How to Deploy a Python Dash App on Pythonanywhere.com

Here’s the step-by-step approach of how to deploy your Dash app on Pythonanywhere.com using Flask and pip: Create an account on Pythonanywhere.com. Create a Flask application. Create a Dash application. Copy the Dash app into the Flask app. Connect the Flask server with the Dash app. Modify the WSGI configuration file. Install Dash with pip …

[Dash + Flask] How to Deploy a Python Dash App on Pythonanywhere.com Read More »

Python One-Line Password Generator

Can you believe it? People use unknown and potentially insecure websites to generate their random passwords! This works as follows: A website generates a “random” password for them and they copy&paste it and assume this is a safe password because of the randomness of the characters. What a security flaw! Why? Because the website could …

Python One-Line Password Generator Read More »

How to Solve Python “TypeError: ‘int’ object is not iterable”?

It’s quite common for your code to throw a typeerror, especially if you’re just starting out with Python. The reason for this is that the interpreter expects variables of certain types in certain places in the code. We’ll look at a specific example of such an error: “typeerror: ‘int’ object is not iterable”. Exercise: Run …

How to Solve Python “TypeError: ‘int’ object is not iterable”? Read More »