Advertisement
teslariu

raise

Aug 17th, 2022
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def sumar(a,b):
  5.     """Script que toma como argumentos dos numeros y retorna su suma"""
  6.     if not isinstance(a,(int,float)) or not isinstance(b,(int,float)):
  7.         raise TypeError("Debes usar nĂºmeros como parĂ¡metros")
  8.     return a+b
  9.    
  10. print(sumar(2,3))
  11. print(sumar("2","3"))
  12. print(sumar([1,2,3],[45,4]))
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement