Advertisement
teslariu

func-exc

Oct 25th, 2021
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def sumar(a,b):
  5.     if not isinstance(a,(int, float)) or not isinstance(b,(int, float)):
  6.         raise TypeError("Se requieren dos nĂºmeros")
  7.     return a + b
  8.    
  9. print(sumar(2,3))
  10. print(sumar("Hola ", "chau"))
  11. print(sumar((1,2,30),("hola",True)))
Advertisement
RAW Paste Data Copied
Advertisement