Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- "def ingresar_entero():
- while True:
- try:
- entero = int(input("Ingrese un entero: "))
- except ValueError:
- print("Error. No has ingresado un entero")
- else:
- break
- return entero
- a = ingresar_entero()
- b = ingresar_entero()
- print(f"La suma de {a} y {b} es {a+b}")
- """
- def sumar(a,b):
- """Función que suma dos números"""
- if not isinstance(a,(int,float)) or not isinstance(b,(int,float)):
- raise TypeError("Se requieren dos números")
- return a + b
- try:
- total = sumar("Hola", "Chau")
- except TypeError:
- print("Debes usar nros")
- else:
- print(total)
Advertisement
Add Comment
Please, Sign In to add comment