I'm following a youtube tutorial on doing OOP, and in this tutorial, he said that you can indicate which data type you can pass in a parameter by using var: datatype (i.e Name: str). And then he showed the error message when you try to input something that is not a str type. But when I try to do it, my program still runs without any error?
class Item:
def __init__ (self, name, price: str , quantity):
self.name = name
self.price = price
self.quantity = quantity
def calculate_total_price(self):
return self.price * self.quantity
item1 = Item("Phone",10,20)
print(item1.calculate_total_price())
OUTPUT:
200
In the code above, I made the price parameter only take in str data types, but when I try to run it, it still runs without any error?