Data structures

How it works under the hood

  • List

These are examples of sequence and they have membership test e.g. in or not in. Apple in fruits.

For list and tuple these are O(n)

For set and dict it’s O(1) since they use hashing

There are three control flow statements in Python — if, for and while.

The continue statement is used to tell Python to skip the rest of the statements in the current loop block and to continue to the next iteration of the loop.

The break statement is used to break out of a loop statement i.e. stop the execution of a looping statement, even if the loop condition has not become False or the sequence of items has not been completely iterated over.

An important note is that if you break out of a for or while loop, any corresponding loop else block is not executed.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store