Python3 vs Python2 – The Final Showdown

The Differences Between Python3 and Python2… Who will win?!


Python3 is the new version of Python2, There is no support for Python2 at this moment, But There are some people Who still use it until this day.
Undoubtedly I would recommend anyone to use Python3, Especially if you’re getting started.

The Big Differences Between Them

Firstly and most importantly

The Print Statement

Python2:

print "Python2 is here"

Python3:

print("Python3 is here")

The Input Statement

Python2:

raw_input() – For Strings only
input() – For Integers (Numbers) only

string = raw_input("Give Me Strings only: ")
int = input("Give Me Integer only: ")

Python3:

input() – For All Kinds Of Input

something = input("Give Me Something (Please no EOF): ")
Shame on you!

Variables In The Print Statement

That might be a weird one But Still True

Python2

msg = "Hi"
print("The message entered is % " % msg)

Python3

msg = "Hi" 
print("The message entered is {0} ").format(msg))

Not Equal Operator

Python2

1 <> 2

Python3

1 != 2

There Are Allot Of Other Differences

I covered what I think are the most important ones
And as an Unknown once said:

I Love you all 😛

Unknown

~ViloDium


Sources:

[askpython]
[aipython]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s