Member-only story

10 lesser-known facts about python

Allwin Raju
3 min readOct 6, 2021

--

Photo by Dan Dennis on Unsplash
  1. Python is the only language to have an else condition for a “for loop”. It executes if the for loops terminates normally without any “break”.
for loop with else

The else will be fired if there’s no even number on the list.

2. You can assign () to [], but not the other way round.

list and tuple assignment

The reason is [] is an empty list and () is an empty tuple. Tuples are immutable meaning you can’t change them once created.

3. Python uses indentation to mark blocks whereas other languages use braces. If you run “from __future__ import braces”, you’ll get -

indentation for braces

it’s a joke, meaning even in the future, Python won’t use braces.

4. You can assign different values to different variables at the same time.

--

--

Responses (3)