TEMPLATE in Python

from typing import TypeVar, Generic, List

T = TypeVar('T')

class Stack(Generic[T]):
def __init__(self) -> None:
# Create an empty list with items of type T
self.items: List[T] = []

def push(self, item: T) -> None:
self.items.append(item)

def pop(self) -> T:
return self.items.pop()

def empty(self) -> bool:
return not self.items
# Construct an empty Stack[int] instance
stack = Stack[int]()
stack.push(2)
stack.pop()
stack.push('x') # Type error
2. do while loop in Python
The do while loop is used to check condition after executing the statement. It is like while loop but it is executed at least once.
i = 1
while True:
print(i)
i = i + 1
if(i > 5):
break

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to use Cinemachinie Virtual Camera Extensions: Storyboards

The Quick Overview of AWS Organizations

Diagram showing AWS Organizations hierarchy, with a single root and layers of Organizational Units (OUs) above accounts.

Creating an iOS Place Picker / Places Autocomplete / Search UI using Mapbox API

Become a community builder and earn $PRTR

Waterbear Cloud Newsletter, November 2019

Day 3 @ CoderAcademy

Why isn’t code reused in Microsoft Dynamic projects?

DevOp Maturity Model: why culture, metrics and practices matter.

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
parthanaboina praveen

parthanaboina praveen

More from Medium

Log4Shell: The New Zero-Day Vulnerability in Log4j

Welshcorgicoin — Stacks’ Community-driven memecoin

PolkaBridge 1 Year Anniversary -Achievements & Plans for 2022!

PIP Install — Vivado