Python 2 to 3 Converter

Convert Python 2 code to Python 3 code efficiently and accurately

🚀 316,174 total conversions (105 this month)

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Dot Product of Two Vectors

Multiply two vectors element by element and add the results: the core operation of every neuron.

You'll learn VectorsDot product
Neural networksaimachine learning
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Count Pairs With a Sum

Count pairs of positions whose values add up to a target.

You'll learn Pairs of indexesAvoiding double counts
ArraysBeginnerLearning-pathNested-loops
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Join Customers and Orders

Join customers with their orders like a LINQ Join and report each customer's total spend.

You'll learn LINQ JoinGrouping
ArraysSorting
No solutions yet
Easy

To-Do List

Keep a list of tasks: add them, mark them done, remove them and report what is still pending.

You'll learn Typed collectionsRecords
BeginnerSimulationStrings
No solutions yet
Easy

Linked List Operations

Simulate a linked list: add at either end, remove from the front or by value, and reverse it.

You'll learn Linked listsSimulation
Data-structuresSimulation
No solutions yet
Easy

Sum a Flat JSON Object

Parse a flat JSON object whose values are integers and add up the values.

You'll learn JSON parsingString splitting
ParsingStrings
No solutions yet
Easy

WhenAll Total Time

Find how long a program takes when each group of tasks runs together with Task.WhenAll and groups run one after another.

You'll learn Async/awaitTask.WhenAll
ArraysBeginner
No solutions yet
Medium

Parallel Task Completion Order

Run tasks concurrently with at most k at a time and report the order in which they finish.

You'll learn ConcurrencyPriority queues
SimulationSorting
No solutions yet
Medium

Min Stack

Build a stack that reports its smallest element instantly after any push or pop.

You'll learn StacksRunning minimum
Data-structuresStacks
No solutions yet

What is This Tool?

This free online converter makes it easy to upgrade your legacy Python 2 code to Python 3 instantly. It’s perfect for developers modernizing older projects, fixing compatibility issues, or preparing code for long-term maintenance.

How to Use

  1. Paste or type your Python 2 code into the editor.
  2. Click Convert to generate the Python 3 version.
  3. Download, copy, or share the converted result instantly.

You can also sign in with Google or GitHub to save your conversion history and revisit it anytime.

Why Upgrade to Python 3?

Python 2 reached end-of-life in January 2020, meaning it no longer receives updates or security fixes. Python 3 is now the standard, offering:

  • Better Unicode and string handling
  • Cleaner, more consistent syntax
  • Performance improvements and better libraries
  • Ongoing community and package support

Migrating ensures your code remains secure, maintainable, and compatible with the latest tools and frameworks.

Key Differences Between Python 2 and 3


# Python 2: print is a statement
print "Hello, World!"

# Python 3: print is a function
print("Hello, World!")
    

# Python 2: Integer division
result = 5 / 2  # Outputs 2

# Python 3: True division
result = 5 / 2  # Outputs 2.5
    

Learn more about porting from Python 2 to 3 in the official Python porting guide.

Example Conversions

Basic Input Example

Python 2


print "Enter your name:"
name = raw_input()
print "Hello, " + name
    

Python 3


print("Enter your name:")
name = input()
print("Hello, " + name)
    

Dictionary Iteration


# Python 2
for key, value in my_dict.iteritems():
    print key, value

# Python 3
for key, value in my_dict.items():
    print(key, value)