mardi 5 octobre 2021

How do I check that Variable has type List[str]? [duplicate]

x = ['string1','string1','string1']

How do I check that x has type List[str]?

if type(x) != List[str]:
   raise ValueError("x should be list of str")

This if condition returns True and raise Error but should not.

Aucun commentaire:

Enregistrer un commentaire